Internet encoding

In my project, I load data from Internet.

This example represent the set-up. The project is little wider to explain all details…

Example:
exampledomain.com/load/loadUserSetttings.aspx?userID=23

In HTML, I simply print the settings.

In Xojo, I use the button, to see the settings.

[code] DIM http as New HTTPSocket
http.Yield = TRUE
DIM strPage As String = http.Get(“http://exampledomain.com/load/loadUserSetttings.aspx?userID=23” , 30)

MsgBox decodeURLComponent(strPage)[/code]

These things don’t work:

MsgBox decodeURLComponent(strPage) MsgBox encodeURLComponent(strPage) MsgBox strPage

Or! To be more specific! All works fine, except the Swedish characters!! :slight_smile: Me being an international dude find this quite important!
How to find the solution!?
There are so many places to change the CHARSET that I am simply out of ideas!
(When INSERTING data, when reading data, when showing data, in Xojo…)

EncodeURLComponent and DecodeURLComponent aren’t related to text encodings. Use DefineEncoding to specify the encoding of a string and ConvertEncoding to change the encoding.

strPage = DefineEncoding(strPage, Encodings.UTF8 )

Thank you!
Oh, I think these encoding-issues are difficult! Different languages, different software, different environments…!
It will be VERY interesting to see if these things also work when using Mac and Linux!! Time will tell!!

But I can tell from this point of view, it’s a potential trap-door…!

Can I please ask you, users around the world, to create a new project, paste the code in a button and send the screen to me or paste in the thread? Do you see different than above? Or the same?

DIM http as New HTTPSocket http.Yield = TRUE DIM strPage As String = http.Get("http://vadstenakonstrunda.se/users.asp" , 30) strPage = DefineEncoding(strPage, Encodings.UTF8 ) MsgBox strPage

If you have Windows, two generations old* and the Swedish operating system you need not to compile the code…
It works!
But I know, there are some people out there with a different set up! :slight_smile:

*) I don’t know what Windows version as I have. It’s not ten, not the previous but the version before the previous…

The definition of the encoding usually is in the header part of the html. If you only parse one page then UTF8 is okay. If you want to parse more pages you need to evaluate the header.

Well.
Thank you!
I don’t parse HTML in such sense.
I load text from Internet. If you paste the URL you will see the text… It’s not a secret! Not in such sense!


But later, when posting, I think I need to use HTML headers to get all information correct…

It’s really strange that I run into this error now and not earlier, because I’ve been fiddling with this for quite some time.
Maybe it was similar but not the same!? Or, I did not check for Swedish characters close enough…?

Works for me on Windows 7 (US English edition), which is previous to Windows 8 and Windows 10. I get the exact same output as your screenshot.

Thanks.
Maybe I was more interested in primarily Mac OS and maybe Linux, but since there are no reply I may consider the problem as solved! :slight_smile:

I never try anything on any other platforms…
I’m sure, one day it will not work but also, I can assure, this day is not today! :slight_smile:

Thank you!

One of the big advantages of the new Text type in the new framework is precisely to avoid that kind of problems.

It’s a different thing.
TextType is used within Xojo, for the database, right!?
(Thank you for reminding me, however!!)

“Different software” in this sense refers to Access and Classic ASP to read and write data to that database, using my Xojo project as the User Interface…

Later to be replaced by SQL Server and dot net, I assume!
On top of this comes DreamWeaver to do all the coding for web.
So… Different software means other software than Xojo, still within the Xojo project! :slight_smile:

[quote=214709:@Jakob Krabbe]It’s a different thing.
TextType is used within Xojo, for the database, right!?
(Thank you for reminding me, however!!)

“Different software” in this sense refers to Access and Classic ASP to read and write data to that database, using my Xojo project as the User Interface…

Later to be replaced by SQL Server and dot net, I assume!
On top of this comes DreamWeaver to do all the coding for web.
So… Different software means other software than Xojo, still within the Xojo project! :-)[/quote]

Xojo.Core.Text is what replaces String in the new framework:
http://developer.xojo.com/text