Discussion:
Easy way to convert Mongolian NewtonCTT font to Unicode?
(too old to reply)
BVM
2004-04-26 00:19:36 UTC
Permalink
I've got a bunch of files from the past that were typed in using a
Magicnet font "NewtonCTT". Wondering if there is some way to cut and
paste into the Mongolian Unicode on Windows XP.



--
Learn GRE graduate English vocabulary online:
http://www.internetsage.com
Michael Warmuth
2004-04-26 19:24:18 UTC
Permalink
Hello,
Post by BVM
I've got a bunch of files from the past that were typed in using a
Magicnet font "NewtonCTT". Wondering if there is some way to cut and
paste into the Mongolian Unicode on Windows XP.
I don't know about Windows, but for example a Ruby script
as follows does what you need:

-[ctt2utf8.rb]------------------
#!/usr/local/bin/ruby

if (ARGV.length != 1) then
puts 'Please give output file name.'
exit
end

begin
file = File::open(ARGV[0], 'wb')
rescue
puts "Cannot write-open '#{ARGV[0]}', giving up."
exit 1
end

$stdin.each_byte { | b |
if (b >= 192 && b <= 255) # normal cyrillic letters
outcode = b - 192 + 0xd090
outcode = outcode + 0xc0 if (outcode > 0xd0bf)
file.putc(outcode / 0x100); file.putc(outcode % 0x100)
elsif (b == 170) # caps barred o
file.putc 0xd3; file.putc 0xa8
elsif (b == 186) # barred o
file.putc 0xd3; file.putc 0xa9
elsif (b == 175) # caps straight u
file.putc 0xd2; file.putc 0xae
elsif (b == 191) # straight u
file.putc 0xd2; file.putc 0xaf
else # other character
file.putc b
end
}
---------------------------------

I call it as: ./ctt2utf8.rb outfile.utf < infile.ctt
Of course, this is not cut+paste ;-) Can it be considered
easy anyway?

HTH,

Michael
BVM
2004-04-30 05:54:50 UTC
Permalink
very interesting. I had never heard of "ruby scripts" before. I
downloaded the windows version and the script ran, but when I edit the
file, it looks like the same: still a file with a NewtonCTT font. Or
if I convert the text to Arial, and run the script, then it is
basically the same thing, though the file sizes are different.

I am trying to convert from NewtonCTT (Mongolian font) to Arial with
Mongolian unicode.
Post by Michael Warmuth
Hello,
Post by BVM
I've got a bunch of files from the past that were typed in using a
Magicnet font "NewtonCTT". Wondering if there is some way to cut and
paste into the Mongolian Unicode on Windows XP.
I don't know about Windows, but for example a Ruby script
-[ctt2utf8.rb]------------------
#!/usr/local/bin/ruby
if (ARGV.length != 1) then
puts 'Please give output file name.'
exit
end
begin
file = File::open(ARGV[0], 'wb')
rescue
puts "Cannot write-open '#{ARGV[0]}', giving up."
exit 1
end
$stdin.each_byte { | b |
if (b >= 192 && b <= 255) # normal cyrillic letters
outcode = b - 192 + 0xd090
outcode = outcode + 0xc0 if (outcode > 0xd0bf)
file.putc(outcode / 0x100); file.putc(outcode % 0x100)
elsif (b == 170) # caps barred o
file.putc 0xd3; file.putc 0xa8
elsif (b == 186) # barred o
file.putc 0xd3; file.putc 0xa9
elsif (b == 175) # caps straight u
file.putc 0xd2; file.putc 0xae
elsif (b == 191) # straight u
file.putc 0xd2; file.putc 0xaf
else # other character
file.putc b
end
}
---------------------------------
I call it as: ./ctt2utf8.rb outfile.utf < infile.ctt
Of course, this is not cut+paste ;-) Can it be considered
easy anyway?
HTH,
Michael
BVM
2004-04-30 06:46:28 UTC
Permalink
Reviewing the script, it seems to be doing what its written to do.
What am I supposed to do with the output??? It cannot be changed into
another font. Not sure what to do next aside from retyping in my
Mongolian documents.
Post by BVM
very interesting. I had never heard of "ruby scripts" before. I
downloaded the windows version and the script ran, but when I edit the
file, it looks like the same: still a file with a NewtonCTT font. Or
if I convert the text to Arial, and run the script, then it is
basically the same thing, though the file sizes are different.
I am trying to convert from NewtonCTT (Mongolian font) to Arial with
Mongolian unicode.
Post by Michael Warmuth
Hello,
Post by BVM
I've got a bunch of files from the past that were typed in using a
Magicnet font "NewtonCTT". Wondering if there is some way to cut and
paste into the Mongolian Unicode on Windows XP.
I don't know about Windows, but for example a Ruby script
-[ctt2utf8.rb]------------------
#!/usr/local/bin/ruby
if (ARGV.length != 1) then
puts 'Please give output file name.'
exit
end
begin
file = File::open(ARGV[0], 'wb')
rescue
puts "Cannot write-open '#{ARGV[0]}', giving up."
exit 1
end
$stdin.each_byte { | b |
if (b >= 192 && b <= 255) # normal cyrillic letters
outcode = b - 192 + 0xd090
outcode = outcode + 0xc0 if (outcode > 0xd0bf)
file.putc(outcode / 0x100); file.putc(outcode % 0x100)
elsif (b == 170) # caps barred o
file.putc 0xd3; file.putc 0xa8
elsif (b == 186) # barred o
file.putc 0xd3; file.putc 0xa9
elsif (b == 175) # caps straight u
file.putc 0xd2; file.putc 0xae
elsif (b == 191) # straight u
file.putc 0xd2; file.putc 0xaf
else # other character
file.putc b
end
}
---------------------------------
I call it as: ./ctt2utf8.rb outfile.utf < infile.ctt
Of course, this is not cut+paste ;-) Can it be considered
easy anyway?
HTH,
Michael
Michael Warmuth
2004-05-03 06:11:34 UTC
Permalink
Hello,
Post by BVM
Reviewing the script, it seems to be doing what its written to do.
What am I supposed to do with the output??? It cannot be changed into
another font. Not sure what to do next aside from retyping in my
Mongolian documents.
Oh. I forgot to mention that it needs clear-text input (encoded
as int the char table of ...CTT). So you cannot convert binary
files (as those of Word). You'll have to export them in a clear-
text format as HTML. Than you can use the script which converts
all the character codes. Then, all you should have to do is to
re-import it to your application (and to change the font to an
UTF font probably).

That's the theory, I don't know what special pitfalls are in
your application/OS.

Bye,

Michael

Loading...