Forum Moderators: coopster

Message Too Old, No Replies

mcrypt encode/ decode character encoding

decode showing extra symbols

         

Tommybs

7:04 pm on Jul 7, 2010 (gmt 0)

10+ Year Member



Hi,

I'm trying to use encrypt and decrypt on some data, yet when I decrypt it I am being presented with a little black diamond with a question mark at the end. This question mark is missing from the data initially and only appears on decrypt. After a bit of searching it appears that this is down to character encoding, yet for the life of me I can't find a solution. The charset I'm using is UTF-8 and it looks like it should all be ok.

Anyone know how I can resolve this?

Thanks

jatar_k

2:38 pm on Jul 8, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you need to check the charset matches everywhere

page where data is input
page where data is stored
page where data is output

anything else that possibly touches data
check browser settings as well

Tommybs

2:52 pm on Jul 8, 2010 (gmt 0)

10+ Year Member



The charset is fine everywhere which is what I can't work out. I wasn't storing anything in a DB as of yet. Using trim on the decode seemed to sort this out, but I get the feeling this really isn't the final solution. The browser was fine as well and it was all running on the same page as a test..

jatar_k

3:00 pm on Jul 8, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



did you try the comments on this page
[php.net...]

there is talk about padding and the likes, there might be a clue in there, I didn't read thoroughly, just searched through

coopster

12:30 pm on Jul 9, 2010 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Check for a BOM (byte order mark) too.