Scripting to print extended characters?

Viewing a file in Hex mode I use the ASCII+ANSI and extended characters appear correct.
I’m trying to script so that those extended characters print out properly but I’m failing badly!
What am I doing wrong?

I should clarify a bit. I’m using Printf to view the results in the Output window.
Anything beyound the basic ASCII chartacters results in the unknown character symbol.
Would be nice if the Output window could handle the ASCII+ANSI character set.

Here’s a quick Script that demonstrates the issue.

int ch;

for( ch = 75 ; ch <= 191; ch++ )
Printf(“ASCII+ANSI value = %d, Character = %c\n”, ch , ch );

Hi Jeff

Printf currently expects strings in utf-8 format. If you want to print extended characters you would have to convert them to utf-8 with something like:

int ch;
char str[2];

for( ch = 75 ; ch <= 255; ch++ )
str[0] = ch;
Printf( “ASCII+ANSI value = %x, Character = %s\n”, ch ,
StringToUTF8( str ) );

I’m not sure if we should have a way to switch Printf to accept data in other characters sets but right now just utf-8 works. But the way, I believe there is a bug in our ANSI handling where StringToUTF8 is using the latin1 character set instead of ANSI. This only affects the characters in range 0x80 - 0xa0 which means they won’t be printed out properly and we’ll have to get this fixed up. Cheers!

Graeme Sweet
SweetScape Software

1 Like

Thank you! I’ll test this and see if it handles my issues.
I do have some test files from the original Game to compare to.
On the character range issue? I can just Script around that for now.

Thanks again!

What I did for now was insert the ubyte in a new column so I can see the ANSI value.
Then I open the output file in NotePad++ and insert the needed character. Once that’s done I delete the extra column. I only have 16 or so files to do so it’s not a big deal.