Jump to content

Unicode character test cases


farhan00

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.