Character encoding is driving me insane

Fredrik Andersson fredrik at morbug.se
Tue May 12 10:15:53 EDT 2009


Thanks for the help Mark & Klaus!

I tried a few variants based on the manual and your examples.  
Unfortunately I couldn't get it to work. For instance when I tried to  
set the custom behaviour script of the datagrid columns in question to  
"Set the unicodetext of me to uniencode(pData, "utf8")" I got an error  
message telling me that I couldn't set that property. I've probably  
just misunderstood something (as I usually do).

Anyway, I got it to work (for now at least) by eliminating my  
"importedData"-field and simply using a code like this:

put url("file:" & fld "sökväg" & fld "opid") into tData

... and then putting the different items of each line of tData into an  
array and then into dgData.

All my precious åäöÅÄÖ-characters are now visible in the datagrid. I  
have no idea why this didn't work at first but does work now. I'll  
just enjoy it while I can :)

Regards,

Fredrik

12 maj 2009 kl. 14.27 skrev Mark Schonewille:
> Hi Fredrik,
>
> When you're using unicode, you need to use the unicodeText  
> properties all the time. Instead of putting a field into a variable,  
> you do this:
>
> put the unicodeText of fld "importedData" into tData
>
> The problem now is that tData is not plain text. If all characters  
> in your text can be converted to ASCII characters, you may convert  
> your UTF8 stream to plain text:
>
> put unidecode(uniencode(tFile,"UTF8"),"English") into tData
>
> Let us know whether this works for you.
>
> --
> Best regards,
>
> Mark Schonewille
>
> Economy-x-Talk Consulting and Software Engineering
> http://economy-x-talk.com
> http://www.salery.biz
> Dutch forum: http://runrev.info/rrforum
>
> New: Snapper Screen Recorder 2.0.1
> Download at http://snapper.economy-x-talk.com
>
> On 12 mei 2009, at 13:55, Fredrik Andersson wrote:
>
>> Hi there,
>>
>> I'm writing a small application that's supposed to keep track of  
>> different tasks for certain people at work. I'm using a datagrid to  
>> present the data and simple text files for storage. The problem is  
>> that I tend to lose the characters åäö and ÅÄÖ (which we use a lot  
>> here in Sweden).
>>
>> At first I simply loaded a tab-delimited file into the dgText of  
>> the datagrid but that didn't work.
>>
>> After searching around on the forums/mailing list I found some code  
>> for handling UTF-encoded text and thus I changed the "Open file"- 
>> code to something like this:
>>
>> set the unicodetext of fld "importedData" of card "Data" to   
>> uniencode(tFile,"UTF8")
>>   put the fld "importedData" of card "Data" into tData
>>
>> And then I set the dgText to tData. This worked fine until I  
>> started messing around with making some columns into presenting  
>> calculated values only. Since I didn't need to save the data in  
>> those columns to any file I started using the dgData-property to  
>> only save & load specific fields instead.
>>
>> The problem is that now I lose my special characters. They simply  
>> do not appear in the text. They're still there in the text file,  
>> just not in the "importedData"-field and thus neither in the  
>> datagrid. I have no idea why my first solution suddenly stopped  
>> working. The text file is in the "UTF-8"-format.
>>
>> Does anyone out there have any good ideas of how to work with text  
>> with special characters? Or perhaps you can point me toward a  
>> previous thread with useful info. Right now I know nothing about  
>> character encoding except that they make my life more difficult..  
>> sigh.
>>
>> Thanks,
>>
>> Fredrik Andersson
>
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the use-livecode mailing list