Diffrent Encoding

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
onlinedrivingtest
Forum Newbie
Posts: 3
Joined: Wed Nov 16, 2005 10:02 am
Location: UK

Diffrent Encoding

Post by onlinedrivingtest »

I have this problem that I do not know the encoding of the text I am working with. This makes it difficult to work with mysql as the diffrent encoding can mess up my database.

Whats the best way to do this?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Obviously, the best way is to know what is encoding you're working with.

It means you need either:
  • detect encoding of incoming data; or
  • force particular encoding for incoming data
, whichever suits better, depending on the nature of your application.
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

I may be way off here, but I think that he means the way his text editor encoded PHP files.

I have had this problem before, where if I don't save in ANSI encoding then it just outputs chinese characters when I run the script on my server.

Anyway, if you do mean that, just make sure you Save As everytime you're uncertain and choose ANSI encoding, that's what I do.

If you don't mean anything like the above, don't listen to me :)
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

jayshields wrote:I may be way off here, but I think that he means the way his text editor encoded PHP files.

I have had this problem before, where if I don't save in ANSI encoding then it just outputs chinese characters when I run the script on my server.

Anyway, if you do mean that, just make sure you Save As everytime you're uncertain and choose ANSI encoding, that's what I do.

If you don't mean anything like the above, don't listen to me :)
Weither you are correct or not, this is still an interesting subject. But please do note what editor you are using for future reference. It often a setting in the editor itself tha might cause this. In an win32 enviroment I use UltraEdit. A flick of a checkbox will create the problem you just described, but in a Linux enviroment I never have these issues.

( Please, do not turn this into a thread about what editor is the better. :wink: We have a thread for this. )
onlinedrivingtest
Forum Newbie
Posts: 3
Joined: Wed Nov 16, 2005 10:02 am
Location: UK

Post by onlinedrivingtest »

No it isnt my editor.

I have no way of knowing what encoding the text i am working with is.

Sure i can force the encoding i wish but I am sure you have seen yourself what happens if you go on a chinese website all the letters go to crap.

Asfor a workaround Im working on it :)
Post Reply