How to convert Unicode text to UTF-8 text
The demo will show you how to convert Unicode text to UTF-8 text in C-strings in 6 simple steps.
UTF-8 is a way to encode Unicode texts as 8-bit bytes instead of 16-bit words. UTF-8 has advantages in some cases:
- Your texts are primarily latin characters (ASCII).
- Your old compiler does not understand 16-bit Unicode.
Original C-string with Unicode as 16-bit words:
Modified C-string with Unicode as 8-bit bytes:
With this procedure you can convert both ways between 16-bit and 8-bit Unicode encoding.
How to make the same font from the commandline
Start IconEdit:
C:\IconEdit\IconEdit.exe
Open the Library Font, it can be C-Source .c or Compressed .cbn:
C:\IconEdit\IconEdit.exe C:\Font\T_32x32_b_g2.cbn
Read the text for the optimized font with :O, IconEdit finds the C_Strings and makes a font for the texts in the C-Strings:
C:\IconEdit\IconEdit.exe C:\Font\T_32x32_b_g2.cbn :OC:\Text\Astronomy.c
Set output font name with :F, the name should be related to the input text:
C:\IconEdit\IconEdit.exe C:\Font\T_32x32_b_g2.cbn :OC:\Text\Astronomy.c :FC:\Font\Astronomy_c.c
Set modified output text name with :J, the name should be related to the input text, and have the same type:
C:\IconEdit\IconEdit.exe C:\Font\T_32x32_b_g2.cbn :OC:\Text\Astronomy.c :FC:\Font\Astronomy_c.c :JC:\Text\Astronomy__c.c
Set modified output text C-String type :U, use 8 for UTF-8:
C:\IconEdit\IconEdit.exe C:\Font\T_32x32_b_g2.cbn :OC:\Text\Astronomy.c :FC:\Font\Astronomy_c.c :JC:\Text\Astronomy__c.c :U8
Match output text string character type to the utf-8 format with :M yes:
C:\IconEdit\IconEdit.exe C:\Font\T_32x32_b_g2.cbn :OC:\Text\Astronomy.c :FC:\Font\Astronomy_c.c :JC:\Text\Astronomy__c.c :U8 :My
This generates the text optimized font Astronomy_c.c and a modified text Astronomy__c.c