Writing to file in utf-8

Mark Schonewille m.schonewille at economy-x-talk.com
Wed Sep 3 09:33:49 EDT 2014


Hi,

Please, post a simplified version of your actual script. Without script, 
it is really difficult to see what you're doing wrong.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Installer Maker for LiveCode:
http://qery.us/468

Buy my new book "Programming LiveCode for the Real Beginner" 
http://qery.us/3fi

LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 9/3/2014 15:04, jbv at souslelogo.com wrote:
> Hi Mark,
>
> Thanks for your reply, and sorry for the missing information.
>
> I am on Mac OSX with LC 6.5.2. But a solution that works on different
> platforms would be nice.
>
> As I said, the contents of variable it come from files, which I assume are
> in utf-8 (when I open them in BBedit or TextWrangler, it says UTF-8,
> presumably MacRoman encoded XML files with some UTF8 encoded strings).
>
> I don't use fields; the whole thing goes as follows :
> file 1 -> var 1 -> processing -> var 2 -> file 2
>
> In var 2 and file 2 I need to get a list of mySQL INSERT commands to be
> executed on a server to fill a DB in utf-8.
>
> When I follow your advice, in text file "file 2" the char "é" (for
> instance) is
> replaced by "é" (AFAIR this is the utf8 encodeing for "é"), and apparently
> the file is in utf-8.
>
> The only thing I wonder is : if I insert such strings into a DB, will they
> display
> the "é" as "é" in web pages with an utf-8 charset...
>
> Best,
> JB
>
>
>> Hi Jbv,
>>
>> Lots of information is missing. First of all, which version of LiveCode
>> are you using? There are quite a few differences between 5, 6 and 7.
>>
>> You provide one line of syntax, but it isn't clear where the contents of
>> the it variable comes from, e.g. from a file or a field.
>>
>> It isn't clear if the files are 100% UTF8 or e.g. are they Latin1 or
>> MacRoman encoded XML files with some UTF8 encoded strings? (Not very
>> likely to happen, but perhaps something similar is going on).
>>
>> Generally, if you import a UTF8 file into a field, you do this:
>>
>> put url ("binfile:" & myUrl) into myData
>> put uniEncode(myData,"UTF8") into myData
>> set the unicodeText of fld 1 to myData
>>
>> and to export you use
>>
>> put the unicodeText of fld 1 into myData
>> put uniDecode(myData,"UTF8") into myData
>> put myData into url ("binfile:" & myUrl)
>>
>> This should work with all versions, although LiveCode 7 will have
>> different ways to work with unicode text.
>>
>> --
>> Best regards,
>>
>> Mark Schonewille
>>
>> Economy-x-Talk Consulting and Software Engineering
>> Homepage: http://economy-x-talk.com
>> Twitter: http://twitter.com/xtalkprogrammer
>> KvK: 50277553
>>
>> Installer Maker for LiveCode:
>> http://qery.us/468
>>
>> Buy my new book "Programming LiveCode for the Real Beginner"
>> http://qery.us/3fi
>>
>> LiveCode on Facebook:
>> https://www.facebook.com/groups/runrev/
>>
>> On 9/3/2014 13:28, jbv at souslelogo.com wrote:
>>> Hi list
>>>
>>> I have a script that accumulates successive strings into a file.
>>> Each string comes from utf-8 text files and contains french
>>> characters with accents like "é à ô".
>>> After processing in the script, those strings get accumulated
>>> in other txt files. I need these second serie of files to be in
>>> utf-8 format too.
>>> So I use the following code (found in this LC lesson :
>>> http://lessons.runrev.com/m/4071/l/20441-unicode )
>>>
>>> put (unidecode(it,"utf8") & return) after url tPath
>>>
>>> but when I open the file tPath in a text editor, everything is
>>> replaced by chinese chars...
>>>
>>> What am I missing ?
>>> Thanks in advance.
>>> jbv
>>
>>
>> _______________________________________________
>> 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
>>
>
>
> _______________________________________________
> 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