
Character Set Conversion
FileMaker uses the UTF-8 character set internally, but there may be situations where you need to read from or write to files in different character sets. To facilitate character set conversion, ACF provides two essential functions: "to_utf" and "from_utf." These functions allow you to convert strings between UTF-8 and other character sets, making it easier to handle data in various encodings.
from_utf Function
The "from_utf" function converts a UTF-8 string to a character set specified in the second parameter. This function is particularly useful when you need to convert strings before writing them to files in a specific character set.
to_utf Function
Conversely, the "to_utf" function converts a string from a character set specified in the second parameter to UTF-8. You can employ this function to convert strings after reading them from files encoded in various character sets.
Supported Character Sets
ACF supports a wide range of character sets for conversion. Here are the valid character set specifications:
- windows-874
- Shift_JIS
- GB2312
- KSC5601-1987
- Big5
- windows-1250
- windows-1251
- windows-1252
- windows-1253
- windows-1254
- windows-1255
- windows-1256
- windows-1257
- windows-1258
- US-ASCII
- KOI8-R
- EUC-JP
- KOI8-U
- ISO-8859-1
- ISO-8859-2
- ISO-8859-3
- ISO-8859-4
- ISO-8859-5
- ISO-8859-6
- ISO-8859-7
- ISO-8859-8
- ISO-8859-9
- ISO-8859-13
- ISO-8859-15
- ISO-2022-JP
- ISO-2022-KR
- EUC-KR
- GB18030
Function Prototypes
from_utf Function Prototype
string converted = from_utf(string SourceUTF8String, ToCharacterSet);
SourceUTF8String
: The string containing the UTF-8 string to convert from.ToCharacterSet
: A string containing one of the character sets mentioned above to specify the conversion destination.
to_utf Function Prototype
string destUTF8string = to_utf(string SourceString, FromCharacterSet);
SourceString
: The string containing the text to convert.FromCharacterSet
: A string containing one of the character sets mentioned above to specify the conversion source.
Platform-Specific Implementation
It's important to note that while most conversion codes should work on both Mac and Windows platforms, there may be some differences in implementation. The Mac version of the plugin utilizes the "iconv" library for conversions, while the Windows version uses the boost::locale library. If you encounter specific conversion needs or issues, you can contact the developer for further exploration or refer to the respective libraries for more information.
Example:
string utftext = to_utf("My ISO8859-1 text to be converted", "ISO-8859-1");
string isotext = from_utf(utftext, "ISO-8859-1");
In this example, the "to_utf" function converts a string from ISO-8859-1 to UTF-8, and the "from_utf" function converts it back to ISO-8859-1.
The "from_utf" and "t_utf" functions in ACF provide a convenient way to handle character set conversions when working with different encodings in your FileMaker solutions.