FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Cannot write utf8 data into a utf8 column
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Cannot write utf8 data into a utf8 column - SOLVED [message #170753 is a reply to message #170752] Fri, 19 November 2010 17:03 Go to previous messageGo to previous message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma:
Senior Member
.oO(Tony Marston)

> "Peter H. Coffin" <hellsop(at)ninehells(dot)com> wrote in message
> news:slrniebqgp(dot)1g0(dot)hellsop(at)abyss(dot)ninehells(dot)com...
>>
>> If it were the SAME, it would work the same. MySQL gives this error when
>> there's invalid UTF-8 byte sequences, like a continuation byte without
>> starting byte, or a starting byte that is not followed by a continuation
>> byte... Find out what the hex for what you're trying to stick in
>> message_text and I bet it won't be what it should be.
>
> The error message was reporting a problem with the hex value \xA0 (decimal
> 160) which represents '&nbsp;' or the non-breaking space.

Yes, but 0xA0 is no correct UTF-8 sequence. Only the 128 ASCII chars
(0x00-0x7F) can be written as single-byte sequences. All other chars
require 2 or more bytes.

> I discovered that
> instead of replacing '&nbsp;' with chr(160) that I needed to replace it with
> chr(194).chr(160). I don't now why the chr(194) is necessary, but it solves
> my problem.

0xC2 0xA0 is the correct encoding of the non-breaking space as UTF-8:

http://www.fileformat.info/info/unicode/char/a0/index.htm

If you do such replacements in your scripts, it might make sense to
ensure that all your scripts are stored in UTF-8 as well. Then you don't
have to manually create the correct byte sequences.

Micha
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: store backslash in mysql database
Next Topic: Firewall - NetDefender :
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 22:40:11 GMT 2024

Total time taken to generate the page: 0.04235 seconds