How can I convert a text string to UTF 8?

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
Peter@multidesk.se
Posts: 106
Joined: Fri Oct 14, 2011 6:53 am

How can I convert a text string to UTF 8?

Post by Peter@multidesk.se » Wed Jun 27, 2018 10:39 am

I need to convert a text string to UTF 8? (or something similar that can fix this problem)

The problem is that when I import a .csv file to liveCode, process it, and then saving it on my computer, I get a lot of junk characters in the output file.
The imported file consists of Swedish letters, ie "å,ä,ö" and these are distorted.

What I find about this subject seems to apply to text fields or data grids, and not to a string.

Anyone who knows?


/// Peter
/*Whats all the fuss with c# ?*/

Klaus
Posts: 10409
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How can I convert a text string to UTF 8?

Post by Klaus » Wed Jun 27, 2018 10:45 am

Hi Peter,

this should do the trick:

Code: Select all

...
## Use BINFILE to be sure!
put url("binfile:" & "path/to_your/csv_file.csv") into tOldData
put textdecode(tOldData,"UTF-8") into tClean_data
...
Now save tClean_data to a file on your disk and it should look fine with all accents, umlauts etc.


Best

Klaus

Peter@multidesk.se
Posts: 106
Joined: Fri Oct 14, 2011 6:53 am

Re: How can I convert a text string to UTF 8?

Post by Peter@multidesk.se » Wed Jun 27, 2018 8:18 pm

Thx Claus,

Work like a charm.. :D :D :D

///Peter
/*Whats all the fuss with c# ?*/

Klaus
Posts: 10409
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How can I convert a text string to UTF 8?

Post by Klaus » Wed Jun 27, 2018 8:26 pm

Coooooooooool! :D

Post Reply

Return to “Mac OS”