Web Connection
wwHTTP and special language characters
Gravatar is a globally recognized avatar based on your email address. wwHTTP and special language characters
  Scott R
  All
  Mar 7, 2023 @ 06:03am

Hi Rick,

Not sure if the is the right 'forum' for this question but we have integrated in a translation feature in our app / webservice using another webservice via wwHTTP. The problem we are having is special characters in other languages (i.e. spanish) are not coming through correctly in VFP after we call m.resp = oHTTP.httpGet(m.url2hit).

For example, when I watch the request in Fiddler, I get this:

{"translations":[{"detected_source_language":"EN","text":"PANEL ESCANEAR UN ÁREA DE 10,5'' X 10,5'' LLAMADA EN RUTA"}]}

But when I look at it in VFP or do _cliptext = m.resp it looks like:

{"translations":[{"detected_source_language":"EN","text":"PANEL ESCANEAR UN ÁREA DE 10,5'' X 10,5'' LLAMADA EN RUTA"}]}

Basically the 'Á' becomes 'Á' . Do you have any ideas on how to fix this? I've tried various strconv()s but nothing has helped so far. I'm guessing it's more of a VFP problem but there's got to be some way around this? We are hitting this for any 'special' character, this was just one example. Any thoughts?

Gravatar is a globally recognized avatar based on your email address. re: wwHTTP and special language characters
  Scott R
  Scott R
  Mar 7, 2023 @ 06:47am

Hi Rick,

I think I found the answer? I ended up needing to do a strconv(m.text, 12) and that fixed it and then I could convert it farther from there. Haven't tested this yet for German (which we also support) but seems to be working okay for Spanish. Is this the right approach or should I be doing something else?

Gravatar is a globally recognized avatar based on your email address. re: wwHTTP and special language characters
  Rick Strahl
  Scott R
  Mar 7, 2023 @ 12:45pm

What version are you using? Recent versions should automatically detect and decode UTF8.

UTF8 decoding should be automatic if:

  • loHttp.lDecodeUtf8 = .T. (on by default)
  • Server properly returns Content-Type: application/json; charset=utf8

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: wwHTTP and special language characters
  Scott R
  Rick Strahl
  Mar 7, 2023 @ 12:50pm

Hi Rick,

We are using web connect 6.21. Doesn't look like that property exists on my oHTTP object (unless I'm just blind 😉 ).

Thanks for the reply.

Gravatar is a globally recognized avatar based on your email address. re: wwHTTP and special language characters
  Rick Strahl
  Scott R
  Mar 7, 2023 @ 01:03pm

Definitely existed in 6.21. Not sure if it was set on by default in that version though.

+++ Rick ---

© 1996-2024