How to read special characters NETWEBGET?

Previous topic - Next topic

msx

When I read a XML using NETWEBGET, Special characters are not read properly. For example Á=á, É=é...

Is there any solution to this?  :nw:

spacefractal

#1
I guess is something issue with unicode convertning or such ting, which is unsupported by GlBasic. I guess the string have been formated to Utf8 by system, and then glbasic not checking about format, and fail to convert back again (its my guess).

I think you should give a example code.....
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Kitty Hello

It depends on the encoding of this website. If it's UTF-8, you have to convert it back to ISO-88xx or so.

You can try: "URLDECODe$", which does this (as well as expanding "+" to " ").
Optionally, you could call an inline function:
Code (glbasic) Select

void __GLBASIC__::_utf8decode_glb(DGStr& str);


msx

The XML file I have to read is located on a server outside so I can not handle it, the only option would be that GLB could read it in UTF-8.

How I would use "void __GLBASIC__: _utf8decode_glb (DGStr & str);"?

Kitty Hello

Code (glbasic) Select

LOCAL utf8$ = "Superäöüsuper" // superäöüsuper

STDOUT fromUtf8$(utf8$) + " - äöü\n"
KEYWAIT

FUNCTION _end_main_foo:
ENDFUNCTION





INLINE
void _utf8decode_glb(DGStr& str);
ENDINLINE

FUNCTION fromUtf8$: str$
INLINE
    _utf8decode_glb(str_Str);
ENDINLINE
RETURN str$
ENDFUNCTION

msx

I'll try

Thank you very much. You're still the best  :nw: :nw:

MrTAToad

#6
That comes up with "Super super - äöü" using DEBUG and "Super super - õ÷³" using STDOUT

Kitty Hello

for STDOUT the console-codepage usually is set to Windows. There are ways to change it, but it's just a matter of display.

MrTAToad

I presume that function converts to unicode where available ?

Kitty Hello

No. There's no unicode used at all.