![]() ![]() ![]()
|
SophiaFramework UNIVERSE 5.3 |
The SFXAscii and SFXShiftJIS classes are used to check the character type and convert the character.
Example 11.25. Checking the Type of ASCII Character
AChar x('a'), y('7');
if (SFXAscii::IsAlpha(x)) {
// if x is an alphabet
}
if (SFXAscii::IsDigit(y)) {
// if y is a digit
}
Example 11.26. Checking the Type of Japanese(Shift_JIS) Character
SFXWideString wstr("あいうえおABCDE");
if (SFXShiftJIS::IsFullAlpha(wstr[6])) {
// if the 7th character of wstr is 2-byte alphabet
}
if (SFXShiftJIS::IsFullHiragana(wstr[3])) {
// if the 4th character of wstr is 2-byte Japanese Hiragana
}
The SFXTextEncoding class is used to convert a string from one encoding into another.
Example 11.29. Converting String Code
SFXAnsiString shiftJIS_string("あいうえお"); // string before conversion(Shift_JIS)
SFXAnsiString utf8_string; // string after conversion(UTF-8)
SFXAnsiString utf16be_string; // string after conversion(UTF-16BE)
SFCError error(SFERR_NO_ERROR); // error value
// converting encoding from Shift_JIS to UTF-8
error = ShiftJISToUTF8(shiftJIS_string, &utf8_string);
// converting encoding from UTF-8 to UTF-16BE
error = UTF8ToUTF16BE(utf8_string, &utf16be_string);
![]() |
Prerequisite |
|---|---|
The above code is assumed to be encoded in Shift_JIS. | |
Table 11.3. Character Encoding Conversion Table
| Before: After | UTF-8 | UTF-16BE | UTF-16LE | UTF-32BE | UTF-32LE | Shift_JIS | EUC-JP | EUC-CN |
| UTF-8 | O | O | O | O | O | O | O | |
| UTF-16BE | O | X | O | O | O | O | O | |
| UTF-16LE | O | X | O | O | O | O | O | |
| UTF-32BE | O | O | O | X | O | O | O | |
| UTF-32LE | O | O | O | X | O | O | O | |
| Shift_JIS | O | O | O | O | O | O | X | |
| EUC-JP | O | O | O | O | O | O | X | |
| EUC-CN | O | O | O | O | O | X | X |
|
Copyright(c) 2002 - 2012 Sophia Cradle Incorporated All Rights Reserved. |
![]() ![]() ![]()
|