Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Character Set - Cyrilic

Status
Not open for further replies.

Extension

Programmer
Nov 3, 2004
311
CA
Hi,

I'm having some trouble with an array containing text in Cyrillic (Ukrainian).
I don't have any problems printing Cyrillic text; simply by adding the meta tag for "windows-1251".
But if I want to do a comparison between two strings in Cyrillic; it's not working. Also if I try to "explode" an array containing Cyrillic words; again it's not working. I'm getting some weird non sense characters.

I'm new to php and to character sets and I was wondering if there is a function to handle this.
 
Disclaimer: I'm not an expert when it comes to internationalization or character encodings.

PHP is very stupid when it comes to character encoding. The standard string handling functions generally assume that a character is a single byte with no particular encoding. This means that they start to break down when you use a multi-byte character set or if you try to mix character encodings anywere in your code. This is particularly a problem if you're getting your data from an external source.

It's hard for me to address your specific problems without knowing more about the situation. However, as a more general solution, you might want to look into the mbstring and iconv extensions. Mbstring is not a standard extension, but it's theoretically an "automatic" fix, as it replaces all the non-Unicode-aware functions with ones that are Unicode aware. Iconv is not an "automatic" fix, but it might be useful if you need to convert user input into a specific encoding. It's also standard in PHP 5.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top