Forum > Beginners
[Solved] Unicode escape sequence \u and fpjson
Gerard:
Hi,
I am trying to pick up Pascal again by converting a Python script I wrote to display news items (coming from the Mozilla Pocket API). Having some trouble with Korean text. When having multiple Korean characters often the second character is not displayed. With the simplified example below:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- koreanJsonData := GetJSON('{ "example": "Two unicode characters immediately after each other \uadf8\ub8f9 " }' ); Memo1.Append(koreanJsonData.findpath('example').AsString);
It should display: 그룹 (그 geu and 룹 is roup, basically the word 'group' in Korean)
When not having the space a space between the \u sequences it does not display anything at all without any error.With a space it displays the characters above (with a space in between).
I tried a few variations on the above, but cannot get it to display correctly. Probably I am doing something wrong, or am I encountering a bug?
Best regards,
Gerard
ASerge:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---koreanJsonData := GetJSON('{ "example": "Two unicode characters immediately after each other '#$adf8#$b8f9' " }');
paweld:
On Lazarus trunk and FPC 3.2-fixes is ok:
--- Code: ---Two unicode characters immediately after each other 그룹
--- End code ---
but if FPC 3.2.2 then:
--- Code: ---Two unicode characters immediately after each other 그?
--- End code ---
Gerard:
Thanks, that indeed seems to work with setting a string in code. I might have simplified to much though.
In my complete program I use stringTFPHTTPClient.SimpleGet to get JSON data from the Mozilla Pocket web API. Instead of the string in my example the resulting JSON data from SimpleGet (stored in a string) is the argument for GetJSON().
In that input with multiple \u-characters I get output like this (second character always a question mark): 에?는 최? 국?
I would expect that to be valid JSON-data (the \u escape sequence notation) that should be interpreted by fpjson, right?
Gerard:
--- Quote from: paweld on February 25, 2024, 10:29:17 am ---On Lazarus trunk and FPC 3.2-fixes is ok:
--- Code: ---Two unicode characters immediately after each other 그룹
--- End code ---
but if FPC 3.2.2 then:
--- Code: ---Two unicode characters immediately after each other 그?
--- End code ---
--- End quote ---
Ah, a bug after all, thanks!
Navigation
[0] Message Index
[#] Next page