is JSONToVariant() implicit convert utf-8 to unicode

Startbeitrag von ccc2 am 19.01.2017 04:16

Hi,

is JSONToVariant() implicit convert utf-8 to unicode
in following code seem to suggest it ?

JSon is string = [
{
"RS": "OK",
"DT": "おはようございます"
}
]

v is Variant = JSONToVariant(StringToUTF8(JSon))

info(typevar(v..Member[2]..Value)) -> return 31 wlVariant

IF v..Member[2]..Value = "おはようございます" THEN
Info("good morning")
ELSE
Info("error")
END


can someone confirm?

Antworten:

Hi

I'm not sure what you are asking here...

utf8 is one of the characters encoding that can be used in unicode (also utf16 and others)...

So there is no such thing as a conversion between utf8 and unicode...

Juste google ytf8 vs unicode for more details.

Best regards

von Fabrice Harari - am 19.01.2017 18:23
my guess unicode in Wx is UTF-32 LE which is default use in windows but it's not same with UTF-16 which default use in non-windows (linux, android,...).

for example , I want to send json using httprequest
m_str is string = [
{"sql": "1YfXLBCLc+SnsM+f+snZvusFISfs6YvshlfoN5NxQpfInP/FQA0DfR2mwAbDhHbU"}
]


/////////// with convert to utf-8 /////////////////////////////////////////
m_utf8 is buffer = StringToUTF8(m_str)

IF HTTPRequest(m_Host,"","",m_utf8 ,"application/json",M_user,m_pass) = False THEN

////////tcpdump show

Content-Length: 75
Content-Type: application/json
Accept: */*
Host: 192.168.43.172:3000
User-Agent: PC SOFT Framework
Connection: close
Authorization: Basic dXNlcjE6cGFzczE=

{"sql": "1YfXLBCLc+SnsM+f+snZvusFISfs6YvshlfoN5NxQpfInP/FQA0DfR2mwAbDhHbU"}



/////////// without convert , still unicode /////////////////////////////////////////

IF HTTPRequest(m_Host,"","",m_str ,"application/json",M_user,m_pass) = False THEN

Content-Length: 150
Content-Type: application/json
Accept: */*
Host: 192.168.43.172:3000
User-Agent: PC SOFT Framework
Connection: close
Authorization: Basic dXNlcjE6cGFzczE=

{.".s.q.l.".:. .".1.Y.f.X.L.B.C.L.c.+.S.n.s.M.+.f.+.s.n.Z.v.u.s.F.I.S.f.s.6.Y.v.s.h.l.f.o.N.5.N.x.Q.p.f.I.n.P./.F.Q.A.0.D.f.R.2.m.w.A.b.D.h.H.b.U.".}.



as you can see the different .

the reason that I sending not using FORM ?
1. weird bugs where sometime i get FORM is empty
2. urlEncode will first need to convert unicode to ansi .

von ccc2 - am 20.01.2017 03:50
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.