Updated 2012-11-05 11:24:01 by RLE
encoding convertfrom ?encoding? data

Convert data to Unicode characters from the specified encoding. The characters in data are treated as binary data where the lower 8-bits of each character is taken as a single byte (i.e., data is interpreted as a byte array). The resulting sequence of bytes is treated as a string in the specified encoding. If encoding is not specified, the current system encoding is used.

MG Have a bit of a strange problem, hopefully someone can help. This example script shows what I'm trying to do - it displays cp437-encoded text in a text widget:
text .t -font Term
pack .t
.t insert end [format %c 152]
.t insert end [encoding convertfrom cp437 [format %c 152]]

The Term font being used is available at http://8bit.memoryleak.org/Flag/Term.ttf and is designed for displaying cp437-encoded text.

Character 152 in cp437 is a y-umlaut. However, the first insert displays a placeholder character (a solid down-arrow) instead. The second does display a y-umlaut, but it does so by mapping to character 255, which isn't available in the Term font (because it has no meaning in cp437), so Tcl uses a fallback font, and it looks totally wrong (Term is fixed-width and quite bold; the fallback font, Lucida Sans Unicode, doesn't match up at all).

I can use the Term font in other (non-Tcl) applications, for instance MS Word, and insert char 152, which gives a y-umlaut without any problem. I honestly have no idea what's causing this issue; can anyone shed any light?

See also edit