I have on DB2 table that stores one Json string on one of the fields and I need to get this value and display on a browser, so this is here my problem begins...
Some json string has German chars that for some reason only when I execute the php from a browser gets error 5 on json_last_error()
, if I execute the same script on terminal, it execute with success.
Another thing is, if I get the same json string, and put direct on a var instead of get the var from DB2 using db2_exec()
it works too.
so I built one script to test, and here my tests:
EXECUTING FROM TERMINAL:
message to be decoded:
From DB:
{"location":" Österr","street1":"straße"}
From var:
{"location":" Österr","street1":"straße"}
-------------------------------------------------------------
Json Decode From Var...
stdClass Object
(
[location] => Österr
[street1] => straße
)
-------------------------------------------------------------
Json Error Checking Json Decode Var...
- No errors
-------------------------------------------------------------
Json Decode From DB...
stdClass Object
(
[location] => Österr
[street1] => straße
)
-------------------------------------------------------------
Json Error Checking Json Decode DB...
- No errors
EXECUTING FROM BROWSER:
I already tried:
utf8_encode()
- but this does nothing and the var still the same.
iconv
- get an error saying that there is one invalid char.
I am running out of options to solve this.. I really need help on this.
Thank you.