CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   MySQL (http://www.codingforums.com/forumdisplay.php?f=7)
-   -   base 64 decode in mysql (http://www.codingforums.com/showthread.php?t=273660)

trileletri 09-20-2012 12:14 PM

base 64 decode in mysql
 
Hi,
I have a table column which is base 64 encoded.

Fields are like:
Code:

SQB6AHIAYQBkAGEAIABuAGEAZABzAHQAcgBlAGEBbgBpAGMAZQA=
when i do something like this:
Code:

SELECT base64_decode(opis)
FROM `gsopis`
WHERE `id` =1
LIMIT 0 , 30

Inested of:
Code:

Demontaza armirackog stola.
I get:
Code:

D\0e\0m\0o\0n\0t\0a\0~a\0 \0a\0r\0m\0i\0r\0a\0\rk\0o\0g\0 \0s\0t\0o\0l\0a\0

How can i get rid of unwanted characters? \0 and my language has these šđčćž, they also don't appear in string...

Fou-Lu 09-22-2012 06:39 PM

You'll need to wait for the SQL guys to comment on a fix for this, but it appears to me that its simply a charset issue. The results you have are showing terminators for multibyte, so that would indicate to me that the field it has come from is a multibyte charset, while it should be stored base64 encoded within a 8bit charset like latin.
Of course a better alternative is to simply not use base64 encoding at all and provide the field with the necessary charset to store multibyte characters.

Old Pedant 09-23-2012 11:13 PM

Yeah, FouLu is right. Somehow, you managed to encode it as UTF-16 but now you are decoding it as UTF-8 (or equivalent...in any case, encoded as 16 bit, decoded as 8 bit). Maybe you changed the CHARSET in the meantime? Or maybe you encoded it with something other than MySQL?


All times are GMT +1. The time now is 09:00 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.