Writing accented characters using file_write

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Writing accented characters using file_write

Peter D Bethke
Hello all,

I'm writing out strings to files on OSX server, using file_write. The  
encoding seems to be writing out as (I'm guessing) UTF-8 which OSX  
does not display properly. The character is question is an accented  
character common in romance languages (spanish, french etc), ie "á".

How can I make the string output format correctly when viewed on OSX?

Peter
--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Writing accented characters using file_write

Adam Randall
I wrote this tag some time ago:

<http://www.lassoscripts.com/view_source.lasso?
sid=a67683fa2a00c367&tc=sc>

It should help with what you are doing.

Adam.


--
Adam Randall <[hidden email]>
Quality Assurance / Support
OmniPilot Software, Inc.
http://www.omnipilot.com/
(954) 874-3100
AIM/iChat: adamomni


On Sep 12, 2005, at 3:29 PM, Peter D Bethke wrote:

> Hello all,
>
> I'm writing out strings to files on OSX server, using file_write.  
> The encoding seems to be writing out as (I'm guessing) UTF-8 which  
> OSX does not display properly. The character is question is an  
> accented character common in romance languages (spanish, french  
> etc), ie "á".
>
> How can I make the string output format correctly when viewed on OSX?
>
> Peter
> --
> ------------------------------
> Lasso Support: http://support.omnipilot.com/
> Search the list archives: http://www.listsearch.com/lassotalk.lasso
> Manage your list subscription: http://www.listsearch.com/ 
> lassotalk.lasso?manage
>


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Writing accented characters using file_write

Peter D Bethke
In reply to this post by Peter D Bethke
How do I determine what the proper encoding set is though?


On Sep 12, 2005, at 3:46 PM, Adam Randall wrote:

> I wrote this tag some time ago:
>
> <http://www.lassoscripts.com/view_source.lasso?
> sid=a67683fa2a00c367&tc=sc>
>
> It should help with what you are doing.
>
> Adam.
>
>
> --
> Adam Randall <[hidden email]>
> Quality Assurance / Support
> OmniPilot Software, Inc.
> http://www.omnipilot.com/
> (954) 874-3100
> AIM/iChat: adamomni
>
>
> On Sep 12, 2005, at 3:29 PM, Peter D Bethke wrote:
>
>
>> Hello all,
>>
>> I'm writing out strings to files on OSX server, using file_write.  
>> The encoding seems to be writing out as (I'm guessing) UTF-8 which  
>> OSX does not display properly. The character is question is an  
>> accented character common in romance languages (spanish, french  
>> etc), ie "á".
>>
>> How can I make the string output format correctly when viewed on OSX?
>>
>> Peter
>> --
>> ------------------------------
>> Lasso Support: http://support.omnipilot.com/
>> Search the list archives: http://www.listsearch.com/lassotalk.lasso
>> Manage your list subscription: http://www.listsearch.com/ 
>> lassotalk.lasso?manage
>>
>>
>
>
> --
> ------------------------------
> Lasso Support: http://support.omnipilot.com/
> Search the list archives: http://www.listsearch.com/lassotalk.lasso
> Manage your list subscription: http://www.listsearch.com/ 
> lassotalk.lasso?manage
>


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Writing accented characters using file_write

Adam Randall
In reply to this post by Peter D Bethke
The encoding inside of Lasso is UTF-8, but the output that you want  
is specified in the tag's I recommended. If you specify mac for the  
encoding:

[File_WriteEncoding: 'File/Mac_Roman.txt', 'tést', 'mac']

The file will write out in the mac roman character set with the é  
encoding correctly.

This will write out as ISO Latin 1:

[File_WriteEncoding: 'File/Mac_Roman.txt', 'tést', 'iso-8859-1']

Etc.

Adam.

--
Adam Randall <[hidden email]>
Quality Assurance / Support
OmniPilot Software, Inc.
http://www.omnipilot.com/
(954) 874-3100
AIM/iChat: adamomni


On Sep 12, 2005, at 3:54 PM, Peter D Bethke wrote:

> How do I determine what the proper encoding set is though?
>
>
> On Sep 12, 2005, at 3:46 PM, Adam Randall wrote:
>
>
>> I wrote this tag some time ago:
>>
>> <http://www.lassoscripts.com/view_source.lasso?
>> sid=a67683fa2a00c367&tc=sc>
>>
>> It should help with what you are doing.
>>
>> Adam.
>>
>>
>> --
>> Adam Randall <[hidden email]>
>> Quality Assurance / Support
>> OmniPilot Software, Inc.
>> http://www.omnipilot.com/
>> (954) 874-3100
>> AIM/iChat: adamomni
>>
>>
>> On Sep 12, 2005, at 3:29 PM, Peter D Bethke wrote:
>>
>>
>>
>>> Hello all,
>>>
>>> I'm writing out strings to files on OSX server, using file_write.  
>>> The encoding seems to be writing out as (I'm guessing) UTF-8  
>>> which OSX does not display properly. The character is question is  
>>> an accented character common in romance languages (spanish,  
>>> french etc), ie "á".
>>>
>>> How can I make the string output format correctly when viewed on  
>>> OSX?
>>>
>>> Peter
>>> --
>>> ------------------------------
>>> Lasso Support: http://support.omnipilot.com/
>>> Search the list archives: http://www.listsearch.com/lassotalk.lasso
>>> Manage your list subscription: http://www.listsearch.com/ 
>>> lassotalk.lasso?manage
>>>
>>>
>>>
>>
>>
>> --
>> ------------------------------
>> Lasso Support: http://support.omnipilot.com/
>> Search the list archives: http://www.listsearch.com/lassotalk.lasso
>> Manage your list subscription: http://www.listsearch.com/ 
>> lassotalk.lasso?manage
>>
>>
>
>
> --
> ------------------------------
> Lasso Support: http://support.omnipilot.com/
> Search the list archives: http://www.listsearch.com/lassotalk.lasso
> Manage your list subscription: http://www.listsearch.com/ 
> lassotalk.lasso?manage
>


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Writing accented characters using file_write

Adam Randall
In reply to this post by Peter D Bethke
Doing a little more work than I did, I found I made some mistakes,  
and there's a need for the code to be updated if you are running LP8.

Here's the Lasso 7 version:

<?LassoScript

define_tag: 'File_WriteEncode',
     -required = 'file',
     -required = 'data',
     -type = 'string',
     -optional = 'charset',
     -optional = 'fileoverwrite';

     if: !(local_defined: 'charset');
         local: 'charset' = $__encoding__;
     /if;

     local: 'b' = bytes;
     #b->(importstring: #data, #charset);
     fail_if: !#b->size && #data->size, '-1', 'Character set was  
invalid.';

     local: 'writeparams' = params;
     #writeparams->(remove: 2);
     #writeparams->(insert: #b, 2);

     \file_write->(run:
         -params = #writeparams,
         -name = 'file_write');

/define_tag;

File_Create: 'Files/Mac_Roman.txt', -fileoverwrite;
File_WriteEncode: 'Files/Mac_Roman.txt', 'tést\n', -CharSet = 'mac';

?>

Here's the Lasso 8 Version:

[

define_tag: 'File_WriteEncode',
     -required = 'file',
     -required = 'data',
     -type = 'string',
     -optional = 'charset',
     -optional = 'fileoverwrite';

     if: !(local_defined: 'charset');
         local: 'charset' = $__encoding__;
     /if;

     local: 'b' = bytes;
     #b->(importstring: #data, #charset);
     fail_if: !#b->size && #data->size, '-1', 'Character set was  
invalid.';

     local: 'writeparams' = params;
     #writeparams->(remove: 2);
     #writeparams->(insert: #b, 2);

     \file_write->(run:
         -params = #writeparams,
         -name = 'write');

/define_tag;

File_Create: 'Files/Mac_Roman.txt', -fileoverwrite;
File_WriteEncode: 'Files/Mac_Roman.txt', 'tést\n', -CharSet = 'mac';

]

Enjoy.

Adam.


--
Adam Randall <[hidden email]>
Quality Assurance / Support
OmniPilot Software, Inc.
http://www.omnipilot.com/
(954) 874-3100
AIM/iChat: adamomni


On Sep 12, 2005, at 5:02 PM, Adam Randall wrote:

> The encoding inside of Lasso is UTF-8, but the output that you want  
> is specified in the tag's I recommended. If you specify mac for the  
> encoding:
>
> [File_WriteEncoding: 'File/Mac_Roman.txt', 'tést', 'mac']
>
> The file will write out in the mac roman character set with the é  
> encoding correctly.
>
> This will write out as ISO Latin 1:
>
> [File_WriteEncoding: 'File/Mac_Roman.txt', 'tést', 'iso-8859-1']
>
> Etc.
>
> Adam.
>
> --
> Adam Randall <[hidden email]>
> Quality Assurance / Support
> OmniPilot Software, Inc.
> http://www.omnipilot.com/
> (954) 874-3100
> AIM/iChat: adamomni
>
>
> On Sep 12, 2005, at 3:54 PM, Peter D Bethke wrote:
>
>
>> How do I determine what the proper encoding set is though?
>>
>>
>> On Sep 12, 2005, at 3:46 PM, Adam Randall wrote:
>>
>>
>>
>>> I wrote this tag some time ago:
>>>
>>> <http://www.lassoscripts.com/view_source.lasso?
>>> sid=a67683fa2a00c367&tc=sc>
>>>
>>> It should help with what you are doing.
>>>
>>> Adam.
>>>
>>>
>>> --
>>> Adam Randall <[hidden email]>
>>> Quality Assurance / Support
>>> OmniPilot Software, Inc.
>>> http://www.omnipilot.com/
>>> (954) 874-3100
>>> AIM/iChat: adamomni
>>>
>>>
>>> On Sep 12, 2005, at 3:29 PM, Peter D Bethke wrote:
>>>
>>>
>>>
>>>
>>>> Hello all,
>>>>
>>>> I'm writing out strings to files on OSX server, using  
>>>> file_write. The encoding seems to be writing out as (I'm  
>>>> guessing) UTF-8 which OSX does not display properly. The  
>>>> character is question is an accented character common in romance  
>>>> languages (spanish, french etc), ie "á".
>>>>
>>>> How can I make the string output format correctly when viewed on  
>>>> OSX?
>>>>
>>>> Peter
>>>> --
>>>> ------------------------------
>>>> Lasso Support: http://support.omnipilot.com/
>>>> Search the list archives: http://www.listsearch.com/lassotalk.lasso
>>>> Manage your list subscription: http://www.listsearch.com/ 
>>>> lassotalk.lasso?manage
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> ------------------------------
>>> Lasso Support: http://support.omnipilot.com/
>>> Search the list archives: http://www.listsearch.com/lassotalk.lasso
>>> Manage your list subscription: http://www.listsearch.com/ 
>>> lassotalk.lasso?manage
>>>
>>>
>>>
>>
>>
>> --
>> ------------------------------
>> Lasso Support: http://support.omnipilot.com/
>> Search the list archives: http://www.listsearch.com/lassotalk.lasso
>> Manage your list subscription: http://www.listsearch.com/ 
>> lassotalk.lasso?manage
>>
>>
>
>
> --
> ------------------------------
> Lasso Support: http://support.omnipilot.com/
> Search the list archives: http://www.listsearch.com/lassotalk.lasso
> Manage your list subscription: http://www.listsearch.com/ 
> lassotalk.lasso?manage
>


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage
Reply | Threaded
Open this post in threaded view
|

Re: Writing accented characters using file_write

Peter D Bethke
In reply to this post by Peter D Bethke
Thanks - I did see that it was not working correctly so I extracted  
the bare minimum from it and it worked great:

     local: 'b' = bytes;
     #b->(importstring: 'myáccenteddatá', 'mac');
     file_write: '/foo.txt', #b;

Thanks for tipping me on to the importstring member tag - its cool!  
I'm not a big user of the bytes datatype but this should point me in  
some new directions.

Peter



On Sep 12, 2005, at 5:30 PM, Adam Randall wrote:

> Doing a little more work than I did, I found I made some mistakes,  
> and there's a need for the code to be updated if you are running LP8.
>
> Here's the Lasso 7 version:
>
> <?LassoScript
>
> define_tag: 'File_WriteEncode',
>     -required = 'file',
>     -required = 'data',
>     -type = 'string',
>     -optional = 'charset',
>     -optional = 'fileoverwrite';
>
>     if: !(local_defined: 'charset');
>         local: 'charset' = $__encoding__;
>     /if;
>
>     local: 'b' = bytes;
>     #b->(importstring: #data, #charset);
>     fail_if: !#b->size && #data->size, '-1', 'Character set was  
> invalid.';
>
>     local: 'writeparams' = params;
>     #writeparams->(remove: 2);
>     #writeparams->(insert: #b, 2);
>
>     \file_write->(run:
>         -params = #writeparams,
>         -name = 'file_write');
>
> /define_tag;
>
> File_Create: 'Files/Mac_Roman.txt', -fileoverwrite;
> File_WriteEncode: 'Files/Mac_Roman.txt', 'tést\n', -CharSet = 'mac';
>
> ?>
>
> Here's the Lasso 8 Version:
>
> [
>
> define_tag: 'File_WriteEncode',
>     -required = 'file',
>     -required = 'data',
>     -type = 'string',
>     -optional = 'charset',
>     -optional = 'fileoverwrite';
>
>     if: !(local_defined: 'charset');
>         local: 'charset' = $__encoding__;
>     /if;
>
>     local: 'b' = bytes;
>     #b->(importstring: #data, #charset);
>     fail_if: !#b->size && #data->size, '-1', 'Character set was  
> invalid.';
>
>     local: 'writeparams' = params;
>     #writeparams->(remove: 2);
>     #writeparams->(insert: #b, 2);
>
>     \file_write->(run:
>         -params = #writeparams,
>         -name = 'write');
>
> /define_tag;
>
> File_Create: 'Files/Mac_Roman.txt', -fileoverwrite;
> File_WriteEncode: 'Files/Mac_Roman.txt', 'tést\n', -CharSet = 'mac';
>
> ]
>
> Enjoy.
>
> Adam.
>
>
> --
> Adam Randall <[hidden email]>
> Quality Assurance / Support
> OmniPilot Software, Inc.
> http://www.omnipilot.com/
> (954) 874-3100
> AIM/iChat: adamomni
>
>
> On Sep 12, 2005, at 5:02 PM, Adam Randall wrote:
>
>
>> The encoding inside of Lasso is UTF-8, but the output that you  
>> want is specified in the tag's I recommended. If you specify mac  
>> for the encoding:
>>
>> [File_WriteEncoding: 'File/Mac_Roman.txt', 'tést', 'mac']
>>
>> The file will write out in the mac roman character set with the é  
>> encoding correctly.
>>
>> This will write out as ISO Latin 1:
>>
>> [File_WriteEncoding: 'File/Mac_Roman.txt', 'tést', 'iso-8859-1']
>>
>> Etc.
>>
>> Adam.
>>
>> --
>> Adam Randall <[hidden email]>
>> Quality Assurance / Support
>> OmniPilot Software, Inc.
>> http://www.omnipilot.com/
>> (954) 874-3100
>> AIM/iChat: adamomni
>>
>>
>> On Sep 12, 2005, at 3:54 PM, Peter D Bethke wrote:
>>
>>
>>
>>> How do I determine what the proper encoding set is though?
>>>
>>>
>>> On Sep 12, 2005, at 3:46 PM, Adam Randall wrote:
>>>
>>>
>>>
>>>
>>>> I wrote this tag some time ago:
>>>>
>>>> <http://www.lassoscripts.com/view_source.lasso?
>>>> sid=a67683fa2a00c367&tc=sc>
>>>>
>>>> It should help with what you are doing.
>>>>
>>>> Adam.
>>>>
>>>>
>>>> --
>>>> Adam Randall <[hidden email]>
>>>> Quality Assurance / Support
>>>> OmniPilot Software, Inc.
>>>> http://www.omnipilot.com/
>>>> (954) 874-3100
>>>> AIM/iChat: adamomni
>>>>
>>>>
>>>> On Sep 12, 2005, at 3:29 PM, Peter D Bethke wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> Hello all,
>>>>>
>>>>> I'm writing out strings to files on OSX server, using  
>>>>> file_write. The encoding seems to be writing out as (I'm  
>>>>> guessing) UTF-8 which OSX does not display properly. The  
>>>>> character is question is an accented character common in  
>>>>> romance languages (spanish, french etc), ie "á".
>>>>>
>>>>> How can I make the string output format correctly when viewed  
>>>>> on OSX?
>>>>>
>>>>> Peter
>>>>> --
>>>>> ------------------------------
>>>>> Lasso Support: http://support.omnipilot.com/
>>>>> Search the list archives: http://www.listsearch.com/ 
>>>>> lassotalk.lasso
>>>>> Manage your list subscription: http://www.listsearch.com/ 
>>>>> lassotalk.lasso?manage
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> ------------------------------
>>>> Lasso Support: http://support.omnipilot.com/
>>>> Search the list archives: http://www.listsearch.com/lassotalk.lasso
>>>> Manage your list subscription: http://www.listsearch.com/ 
>>>> lassotalk.lasso?manage
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>> ------------------------------
>>> Lasso Support: http://support.omnipilot.com/
>>> Search the list archives: http://www.listsearch.com/lassotalk.lasso
>>> Manage your list subscription: http://www.listsearch.com/ 
>>> lassotalk.lasso?manage
>>>
>>>
>>>
>>
>>
>> --
>> ------------------------------
>> Lasso Support: http://support.omnipilot.com/
>> Search the list archives: http://www.listsearch.com/lassotalk.lasso
>> Manage your list subscription: http://www.listsearch.com/ 
>> lassotalk.lasso?manage
>>
>>
>
>
> --
> ------------------------------
> Lasso Support: http://support.omnipilot.com/
> Search the list archives: http://www.listsearch.com/lassotalk.lasso
> Manage your list subscription: http://www.listsearch.com/ 
> lassotalk.lasso?manage
>


--
------------------------------
Lasso Support: http://support.omnipilot.com/
Search the list archives: http://www.listsearch.com/lassotalk.lasso
Manage your list subscription:  
http://www.listsearch.com/lassotalk.lasso?manage