- Posts: 16
COMMUNITY FORUM
Extra fields encoding problem
- demonas
-
Topic Author
- Offline
- New Member
Less
More
13 years 9 months ago #99193
by demonas
Extra fields encoding problem was created by demonas
Hi there,
I would like to get a value from an extra field to a custom php I am building. Problem is that the value is a Greek sentence and its stored in the DB as =>
\u00ab\u039a\u03b1\u03c4\u03b1\u03b4\u03c5\u03b8\u03b5\u03af\u03c4\u03b5\u00bb \u03b1\u03bd\u03ad\u03bc\u03b5\u03bb\u03b1 \u03c3\u03b5 \u03bc\u03b9\u03b1 \u03b8\u03ac\u03bb\u03b1\u03c3\u03c3\u03b1 \u2026 \u03bc\u03c0\u03cd\u03c1\u03b1\u03c2 \u03c3\u03c4\u03b7\u03bd \u039a\u03b1\u03b9\u03c3\u03b1\u03c1\u03b9\u03b1\u03bd\u03ae
How I can decode this thing? I tried with no luck:
mb_convert_encoding($text, "HTML-ENTITIES", "UTF-8");
Or if this is difficult how I can store the normal Greek characters in the db right from the start so I don't have to decode anything?
I would like to get a value from an extra field to a custom php I am building. Problem is that the value is a Greek sentence and its stored in the DB as =>
\u00ab\u039a\u03b1\u03c4\u03b1\u03b4\u03c5\u03b8\u03b5\u03af\u03c4\u03b5\u00bb \u03b1\u03bd\u03ad\u03bc\u03b5\u03bb\u03b1 \u03c3\u03b5 \u03bc\u03b9\u03b1 \u03b8\u03ac\u03bb\u03b1\u03c3\u03c3\u03b1 \u2026 \u03bc\u03c0\u03cd\u03c1\u03b1\u03c2 \u03c3\u03c4\u03b7\u03bd \u039a\u03b1\u03b9\u03c3\u03b1\u03c1\u03b9\u03b1\u03bd\u03ae
How I can decode this thing? I tried with no luck:
mb_convert_encoding($text, "HTML-ENTITIES", "UTF-8");
Or if this is difficult how I can store the normal Greek characters in the db right from the start so I don't have to decode anything?
Please Log in or Create an account to join the conversation.
- demonas
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 16
13 years 9 months ago #99194
by demonas
Replied by demonas on topic Extra fields encoding problem
After some hours and a lot of search I solved again by myself. I am posting it in case that helps someone.
$extra_fields = $row_query; // get the extra fields value from db $test = json_decode($extra_fields); // all the trick $array = (array) $test; // convert object to array
So now you have a clear array and you can get any variable from the extra_fields.
$extra_fields = $row_query; // get the extra fields value from db $test = json_decode($extra_fields); // all the trick $array = (array) $test; // convert object to array
So now you have a clear array and you can get any variable from the extra_fields.
Please Log in or Create an account to join the conversation.
- william white
-
- Offline
- Platinum Member
Less
More
- Posts: 3722
13 years 9 months ago #99195
by william white
Replied by william white on topic Extra fields encoding problem
Thanks for posting....nice for the bag of tricks...json_decode!
Please Log in or Create an account to join the conversation.
- demonas
-
Topic Author
- Offline
- New Member
Less
More
- Posts: 16
13 years 9 months ago #99196
by demonas
Replied by demonas on topic Extra fields encoding problem
As for my second question "Or if this is difficult how can I store the normal Greek characters in the db right from the start so I don't have to decode anything?"
The answer is that you really don't have to do something special. If the mysql row is encoded with utf8_general_ci you just make a normal insert. Of course you must make the JSON variables with a function. I don't see any problem in my layout with this.
I am really glad William that you found it interesting;
The answer is that you really don't have to do something special. If the mysql row is encoded with utf8_general_ci you just make a normal insert. Of course you must make the JSON variables with a function. I don't see any problem in my layout with this.
I am really glad William that you found it interesting;
Please Log in or Create an account to join the conversation.