farhan00 Posted December 4, 2008 Share Posted December 4, 2008 I am trying to run a test-case against a unicode character. For example: if (mb_substr($text,1,0,"UTF-8") == [iNSERT FOREIGN CHARACTER HERE] ) The problem is, I'm having trouble with the [iNSERT FOREIGN CHARACTER HERE] part. Lets suppose I want the Arabic character ب, which according to Unicode 0628. Do I do "\u0628"? Do I do "\x0628"? I tried: echo "\x0628"; but it atually echoed \x0628 instead of the Arabic character. Any ideas on who a successful test-case with a unicode character would work? Link to comment https://forums.phpfreaks.com/topic/135451-unicode-character-test-cases/ Share on other sites More sharing options...
haku Posted December 4, 2008 Share Posted December 4, 2008 You should just use the character itself in quotes, same as you would with alphabetic characters. Although you may have troubles due to the encoding being UTF-8. I don't know if arabic encodings work the same as Japanese encodings (actually, I don't even know if that is arabic), but UTF-8 doesn't work well with Japanese, so functions like mb_substr() don't always work so well. Link to comment https://forums.phpfreaks.com/topic/135451-unicode-character-test-cases/#findComment-705719 Share on other sites More sharing options...
farhan00 Posted December 4, 2008 Author Share Posted December 4, 2008 The problem is, if I am writing this code over a simple Unix console, I cannot include Arabic characters, so I need the escape sequence (if any) to work. Link to comment https://forums.phpfreaks.com/topic/135451-unicode-character-test-cases/#findComment-706059 Share on other sites More sharing options...
effigy Posted December 4, 2008 Share Posted December 4, 2008 pack("C*", 0xD8, 0xA8); Link to comment https://forums.phpfreaks.com/topic/135451-unicode-character-test-cases/#findComment-706131 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.