UTF8 on LC server

Tom Glod tom at makeshyft.com
Fri Jun 1 08:16:15 EDT 2018


also just fyi ...if u are encoding arrays and u need the character
handling, you need the extra parameter .... arrayencode(myarray,"7.0")



On Fri, Jun 1, 2018 at 7:15 AM, Mark Waddingham via use-livecode <
use-livecode at lists.runrev.com> wrote:

> On 2018-06-01 12:53, Tim Selander via use-livecode wrote:
>
>> Hi Mark,
>>
>> Here is the script. The files I'm using are
>> bamboobabies.com/getjapanesetext.lc, and the text it is getting is
>> bamboobabies.com/news.txt.
>>
>> In the script, there are two lines reading the text file that I've
>> taken turns commenting out....
>>
>> If you can give me any hints, it would be greatly appreciated.
>>
>> Tim Selander
>>
>>
>> <?lc put header "Content-Type: text/html; charset=UTF-8" ?>
>> <!DOCTYPE HTML>
>> <html>
>>     <head>
>>         <meta http-equiv="Content-type" content="text/html; charset=UTF8">
>>         <title>workbench</title>
>>     </head>
>> <body>
>>
>> <?lc
>> --This line loads readable japanese text, but putting char 500 to 550
>> breaks beginning and ending kanji
>> put url "http://bamboobabies.com/news.txt" into vText
>>
>> --When this line is used, none of the put text is readable
>> --put textDecode(url "binfile:bamboobabies.com/news.txt", "utf-8") into
>> vText
>>
>> put line 1 of vText
>>
>> put "<BR><BR><BR><BR>"
>>
>> put char 500 to 550 of vText
>>  ?>
>> </body>
>> </html>
>>
>
> Try this:
>
> <?lc set the outputTextEncoding to "utf-8" ?>
> <?lc put header "Content-Type: text/html; charset=UTF-8" ?>
> <!DOCTYPE HTML>
> <html>
>     <head>
>         <meta http-equiv="Content-type" content="text/html; charset=UTF8">
>         <title>workbench</title>
>     </head>
> <body>
> <?lc
> --This line loads readable japanese text, but putting char 500 to 550
> breaks beginning and ending kanji
> put textDecode(url "http://bamboobabies.com/news.txt", "utf-8") into vText
>
> put line 1 of vText
>
> put "<BR><BR><BR><BR>"
>
> put char 500 to 550 of vText
>  ?>
> </body>
> </html>
>
> The problem you are having is that your text-file is UTF-8, but the engine
> doesn't know that - you need to explicit decode it into a LiveCode string
> using textDecode. You can then manipulate it as chars etc. correctly with
> Unicode. That solves the 'getting data into livecode in the form needed'
> problem.
>
> The other side of the problem is the text encoding used when you do 'put'.
> By default this is 'native' - by setting the outputTextEncoding at the
> start, the engine will automatically encode any strings you 'put' with the
> encoding specified.
>
> Hope this helps!
>
> Mark.
>
> --
> Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
> LiveCode: Everyone can create apps
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the Use-livecode mailing list