Having trouble displaying something other than ascii in a web list box.

I’m having trouble… when I try to add what appears to be unicode (Japanese character set?) to my WebListBox an exception is thrown and my server crashes.

The following two images show the ‘string’ as a series of hex bytes that I presume are UTF-16 or some other encoding other than ASCII or UTF-8

This is the error that is thrown.

Stack: String_ToText String.$ToText%y%s WebResponse._Render%s%o<WebResponse> WebSession._HandleEvent%%o<WebSession>so<_HTTPServer.HTTPRequestContext> WebSession._HandleRequest%i4%o<WebSession>so<_HTTPServer.HTTPRequestContext> WebApplication._HandleHTTPRequest%%o<WebApplication>o<_HTTPServer.HTTPRequestContext> _HTTPServer.HTTPRequestThread.Event_Run%%o<_HTTPServer.HTTPRequestThread> rbframework.dylib$1225 rbframework.dylib$1016

If I define the encoding to UTF16 it sort of works… but I have no idea if it ‘is’ right as i don’t read that language.

Your images don’t show. Next time, just paste the URL.

Japanese should be UTF16.

How do you add to your text ?

To verify what it says and which language it is, use Google translate set to detect language.

This seem to at least get rid of the exception being thrown, however I have no way of knowing if it is rightly rendered’.

if dsc = "Patient's_Name" then v = v.DefineEncoding(Encodings.UTF16) end if ListBox1.AddRow(v)
But then I tried some other 16 bit sets and they rendered as well.
And to complicate matters I think the endianism is little endian, but again who knows.

SpecificCharacterSet is ISO 2022 IR 13 or ISO 2022 IR 6 or ISO 2022 IR 87… but then I don’t know how those map the xojo encodings.
but at least it’s not crashing.

https://www.icloud.com/iclouddrive/0EzSdXYeUEJzLlnN1-kuPd7QQ#dbg1.png
https://www.icloud.com/iclouddrive/0zLLqN48hneRePNHlfvfuD_qg#dbg2.png

The web framework uses JSON to send data to the browsers and as such must be able to convert to UTF8. Looking at the error stack, the error is happening when converting from the supplied string to Text using the String.ToText method, probably because your original string didn’t have any Encoding at all.

So yes, the solution is to define the encoding on any data being sent to the browser.

Japanese.
??? ???=?? ??
Shinjuku tarou = Shinjuku Tar?
??? ??=???
Yokogawa hime = yokokawa hime

One of the above is what I should get but this is what I get.
However this is what I get.
https://www.icloud.com/iclouddrive/00hgZfnAnG-nRKpF_odgCV_og#img3.png

Are these image links working?