last day (15 days later) » 

7:44 PM
0
A: Unicode encode string

hek2mglchr(200) isn't a valid unicode char. You are currently mixing unicode and non unicode encodings. this sounds weird and will not work. If data is binary it is not meant for printing.

 
I've updated the question to be more clear. I know the checkmark works fine. The problem is that it's not just checkmarks I'm encoding. Try chr(200).
 
However, the first paragraph is still correct (check the documentation that I've linked).. Will investigate the chr(200)..
 
It's for logging, not really printing/displaying to the user. I need it to not break my logger when something funny gets in there.
 
I fear if it can be anything, it will break your logger. If it is really binary data use base64 for example. This will not break your logger, however it is not readable anymore (by humans). But that's by design you cannot mix text and binary data.
 
Why's that? With utf8_encode it never returns false (that I've seen), it just doesn't return nice results for valid utf8.
 
7:44 PM
because chr(200) is a valid iso-8859-1 char (even if it is not printable with every font and therefore might look "bad")
 
I'm OK with chr(200) looking bad because it's not valid UTF-8 (which is my page encoding), so long as it's not false.
I've found a fix
 
Hi
 
Hey
 
I'm curious where your input data is coming from
 
If I just check the string with mb_check_encoding then I can conditionally encode it
This particular case arose when I got an SQL exception
it's logged to phpdebugbar which json-encodings everything
including the query, which contained the binary data
which failed, producing invalid javascript, and broke everything on the page
 
7:47 PM
you mean contents of a blob column?
 
precisely; binary(32)
 
:)
delicious
 
anyway, this solution seems to work well enough for me. thanks for your help!
 
ok, no problem .. cu!
 
see ya
 

last day (15 days later) »