Definitions, Some Implications
say "umlaut-u in 437/850 codepage has codepoint 129 (81 hex):"
do cp over 437, 850, 1252
address system "chcp" cp
say "Codepage" cp":" "hex 81:" 81~x2c "decimal: 129:" 129~d2c
end
say
say "umlaut-u in 1252 codepage has codepoint 252 (FC hex):"
do cp over 437, 850, 1252
address system "chcp" cp
say "Codepage" cp":" "hex FC:" FC~x2c "decimal: 252:" 252~d2c
end
Output (Windows):
umlaut-u in 437/850 codepage has codepoint 129 (81 hex):
Active code page: 437
Codepage 437: hex 81: ü decimal: 129: ü
Active code page: 850
Codepage 850: hex 81: ü decimal: 129: ü
Active code page: 1252
Codepage 1252: hex 81: decimal: 129:
umlaut-u in 1252 codepage has codepoint 252 (FC hex):
Active code page: 437
Codepage 437: hex FC: ⁿ decimal: 252: ⁿ
Active code page: 850
Codepage 850: hex FC: ³ decimal: 252: ³
Active code page: 1252
Codepage 1252: hex FC: ü decimal: 252: ü
bsf.iconv(text,fromCodepage,toCodepage) from BSF.CLS to reliably convert from one codepage to another
E.g. if text was encoded in codepage 850 then invoke it as
If converting from/to UTF-8 (unicode) use "utf-8" as codepage argument
word = .OLEObject~New("word.Application")
word~Visible = .true -- make word visible
document = word~documents~add -- add new document
textEncoding=document~textEncoding
say "word's text encoding:" textEncoding
Selection = word~selection
text1 = "The German umlauts: ÄäÖöÜü and the sharp-s: ß." -- cp1252
selection~~typeText("a) text1 (cp1252):" text1)~~typeParagraph
text2 = "The German umlauts: Ž„™”š� and the sharp-s: á." -- cp850
selection~~typeText("b) text2 (cp850):" text2)~~typeParagraph
text3=bsf.iconv(text2,"cp850","cp1252") -- convert text from 850 to 1252
selection~~typeText("c) text3 (cp1252, converted from cp850):" text3)~~typeParagraph
word~quit
::requires "BSF.CLS" -- get ooRexx-Java bridge
word = .OLEObject~New("word.Application")
word~Visible = .true -- make word visible
document = word~documents~add -- add new document
textEncoding=document~textEncoding
say "word's text encoding:" textEncoding
Selection = word~selection
text1 = "The German umlauts: ÄäÖöÜü and the sharp-s: ß." -- cp1252
.bsf.clipBoard~setString("a) text1 (cp1252):" text1, "CP1252")
selection~~paste~~typeParagraph
text2 = "The German umlauts: Ž„™”š� and the sharp-s: á." -- cp850
.bsf.clipBoard~setString("b) text2 (cp850):" text2, "cp850")
selection~~paste~~typeParagraph
-- UTF-8 encoded emoticons: | smiley: | frownie:
text3= "Unicode UTF-8 characters:" "e2 98 ba"x "e2 98 b9"x -- UTF-8
.bsf.clipBoard~setString("c) text3 (UTF-8):" text3, "UTF-8")
selection~~paste~~typeParagraph
word~quit
::requires "BSF.CLS" -- get ooRexx-Java bridge
WU
Prof. Mag. Dr. Rony G. Flatscher
Welthandelsplatz 1
1020 Wien/Vienna
Austria/Europe
www: www.wu.ac.at