GLBasic forum

Main forum => GLBasic - en => Topic started by: msx on 2011-Nov-11

Title: How to read special characters NETWEBGET?
Post by: msx on 2011-Nov-11
When I read a XML using NETWEBGET, Special characters are not read properly. For example Á=á, É=é...

Is there any solution to this?  :nw:
Title: Re: How to read special characters NETWEBGET?
Post by: spacefractal on 2011-Nov-12
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.....
Title: Re: How to read special characters NETWEBGET?
Post by: Kitty Hello on 2011-Nov-14
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);

Title: Re: How to read special characters NETWEBGET?
Post by: msx on 2011-Nov-14
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);"?
Title: Re: How to read special characters NETWEBGET?
Post by: Kitty Hello on 2011-Nov-14
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
Title: Re: How to read special characters NETWEBGET?
Post by: msx on 2011-Nov-14
I'll try

Thank you very much. You're still the best  :nw: :nw:
Title: Re: How to read special characters NETWEBGET?
Post by: MrTAToad on 2011-Nov-15
That comes up with "Super super - äöü" using DEBUG and "Super super - õ÷³" using STDOUT
Title: Re: How to read special characters NETWEBGET?
Post by: Kitty Hello on 2011-Nov-15
for STDOUT the console-codepage usually is set to Windows. There are ways to change it, but it's just a matter of display.
Title: Re: How to read special characters NETWEBGET?
Post by: MrTAToad on 2011-Nov-15
I presume that function converts to unicode where available ?
Title: Re: How to read special characters NETWEBGET?
Post by: Kitty Hello on 2011-Nov-15
No. There's no unicode used at all.