Unicode and Php 4.3.0

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ojav
Forum Newbie
Posts: 2
Joined: Sun May 29, 2005 4:07 pm
Location: Finland

Unicode and Php 4.3.0

Post by ojav »

How do I go about when retrieving data from Mysql (4.1.12) from tables which have charset=utf8. Some of the columns have latin characters, some cyrillic.
Do I have to update to Php 5.0 . I hope not, because I'm not very good in that sort of thing (I just have undergone a torment of one week updating Mysql).

Is "htmlentities" -function the only way to do it? Is there any other way I could make Php understand unicode. I have gotten an impression that in 5.0 it would be a bit more straightforward.

If "htmlentities" is the only way, then how is it actually used?


PS. I think I have made a personal record. I searched Google with string "'php 4.3' mysql unicode cyrillic". I got 2420 hits. But the first three ones were my own messages on different forums
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

I really don't have a clue, but this might be something that would help:
http://php.net/mbstring
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

Unicode is something PHP doesn't really care about much, if you want to get the 8bit charcodes you can decode using utf8decode (or something like that), thus discarding unicode-information... if you want the user to see the unicode just echo it, browser is the responsible part, if you want to use unicode you can force it by using header() ...
HOWEVER, not that if you use unicode, all must be unicode or things will likely start <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> up (such as "åäö" and certain chars).
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

You can always use the http://www.php.net/mbstring extension which works relatively nice ;)
ojav
Forum Newbie
Posts: 2
Joined: Sun May 29, 2005 4:07 pm
Location: Finland

Post by ojav »

OK, I'll go for mbstring. But obviously I have to install it first. That's a hard part.
I installed my server about two years ago. It sure consumed a lot of time and cigarrettes. Since then I've been just using it (designing web pages, using Php and Mysql a lot). I have never since installed anything from a source. Mysql upgrade I did from a bimary source.

Am I supposed to make a change in some Php configuration file and then run "make" and "install" commands? If yes, then I guess it matters in which directory I give these commands. How would my electric brain otherwise know what to make and what to install?

The problem with manuals is that they explain very thoroughly what to do when installing something. But I never found a HOWTO about reinstalling something because some little bit or piece is lacking. I suppose the way of doing this is considered self-evident. But nothing is self-evident for a fifty-one years old newbie, who always will be a newbie, whose memory is lot lower than it was some thirty years ago, and whose hard disk has way too many dead sectors. I hope that you young, able-bodied and -minded do not mind us old and somewhat demented hanging around here in the realm of cyberspace, but stretch a helping hand once more

PS I have SoL Distro Linux with Apache (1.3)
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

sidenote: remember to use unicode yourself too or otherwise things will likely start getting messy. (if you aren't)
Post Reply