How to write copyright symbol to a file with GB2312 encoding?

976 views Asked by At

I want to write the copyright symbol to the footer of a pdf file. The octal code \251 only works when the encoding of the file is latin. (english language) when the output pdf is in chinese, japanese, korean language. The symbol is printed totally different. I already know that the output file has GB2312 encoding and the code for copyright symbol is two byte character \0xAAC2 .

I've been trying to find out how I should print it? Do I have to convert it to utf16 prior to sprintf ing?

1

There are 1 answers

2
Scooter On

If you are using sprintf I think you can do:

unsigned char one = 0xAA;
unsigned char two = 0xC2;
char output_line[20];
sprintf(output_line,"%c%c",one,two);

or, as suggested below:

sprintf(output_line,"\xaa\xc2");