PocketBuilder supports the Unicode standard, a universal character set that encodes the characters of over 650 of the world's languages. Using a single character set to encode data in multiple languages allows you to create a single multilingual application that can process data in different languages rather than creating multiple monolingual applications.
Every application development tool encodes text in a particular character set. PocketBuilder uses Unicode UTF-16, a two-byte encoding format. Therefore, any text you enter while developing your application is in Unicode.
Working with ANSI and Unicode files outside PocketBuilder In WordPad, you can open and save files as ANSI or Unicode. In TextPad, you can open and save files as ANSI or Unicode, and you can determine whether an open file is ANSI or Unicode by viewing its properties.
This section describes how PocketBuilder handles Unicode in several areas of the product. The next two sections, “Importing and exporting DataWindow data” and “Reading and writing text or binary files”, describe how you use these techniques with particular reference to Unicode.
Some fonts do not display Unicode characters correctly or do not work appropriately on all platforms, and the number of fonts available on Pocket PC devices is limited. To ensure consistent display on all platforms, PocketBuilder uses Tahoma as its default font.
If you call external functions in your application, the functions must be defined and compiled with Unicode support. All strings must be passed as Unicode strings. You can call Windows CE API functions. For more information, see “Using external functions”.
You can convert a PocketBuilder application to a PowerBuilder application and vice versa. You must use PocketBuilder to perform both conversions. If you convert a PocketBuilder application to PowerBuilder 10 or higher, you must select the Create Unicode Libraries check box in the Export Pocket to Desktop conversion tool. If you convert the PocketBuilder application to PowerBuilder 9, you must clear the Create Unicode Libraries check box. Unicode characters that are not supported in ANSI environments, however, cannot be converted correctly for PowerBuilder 9 applications.
For more information about the conversion tools, see the User’s Guide.
PocketBuilder allows you to import both ANSI and Unicode files in the System Tree and Library painter, although you cannot import ANSI files at runtime on a handheld device. Exported source (.sr*) files are always in Unicode format. To convert from ANSI to Unicode and from Unicode to ANSI in PocketBuilder, use the FromANSI and ToANSI functions.
PocketBuilder resource (.pkr) files can be in either Unicode or ANSI file format.
Target (.pkt) and workspace (.pkw) files are saved in ANSI format.
The Script view and the file editor accept both Unicode and ANSI file formats. New text files are saved in the Unicode file format.
On the desktop, the SetProfileString function writes to the text file in the format, either ANSI or Unicode, in which it was opened. On a handheld device, the SetProfileString function writes to the text file in Unicode only. To write Unicode characters to an initialization file, open and save the file as Unicode before calling SetProfileString. The ProfileInt and ProfileString functions also require references to valid Unicode files.
Unicode files often have two extra bytes at the start of the file to indicate that they use Unicode byte ordering. On the desktop, PocketBuilder does not require that these two bytes be present in Unicode files. It determines whether the file uses Unicode byte ordering using other methods. However, PocketBuilder applications deployed to a handheld device do require the Unicode byte order mark (BOM) at the beginning of the file.
PocketBuilder also does not always add the two-byte flag to the beginning of files saved with Unicode encoding. A Unicode file that you create in a PocketBuilder application with the FileOpen command does not contain the Unicode byte order mark (BOM) at the beginning of the file when you set the filemode argument to StreamMode!. To include the BOM in a file that you open in stream mode, you can do one of the following:
Create the file by calling FileOpen in line mode, add an innocuous character, such as a single space, then close the file and reopen it in stream mode using the Append! value for the writemode argument.
Call FileWrite or FileWriteEx and pass the 2 byte binary blob “Char(65279)” before the rest of the string that you want to write to the file in stream mode.
The SQL Anywhere ODBC driver supports either ASCII (8-bit) strings or Unicode code (wide character) strings. The UNICODE macro controls whether ODBC functions expect ASCII or Unicode strings. If your application must be built with the UNICODE macro defined, but you want to use the ASCII ODBC functions, then the SQL_NOUNICODEMAP macro must also be defined. For more information, see the SQL Anywhere documentation.