CharToNum Depricated??
J. Landman Gay
jacque at hyperactivesw.com
Wed Sep 18 04:59:33 EDT 2024
I should have thought of that. Line endings are always translated to/from
native unless the file is opened/written in binary, it's been that way
since MetaCard. It's a feature.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On September 17, 2024 10:35:05 AM Bob Sneidar via use-livecode
<use-livecode at lists.runrev.com> wrote:
> Thanks Bernd. But I finally figured out what the issue was. It seems that
> unless the output file is opened binary, any attempt to wrote to a file
> using any of the cr, lf or crlf keywords in LC will result in LC
> auto-converting them to cr, because that is the Macintosh standard. What I
> had to do is to use numToCodepoint() to create a variable containing ascii
> characters 13 and 10 (crlf) and then use that variable to end my lines.
>
> The way I actually figured out what the issue was, is I downloaded
> Notepad++ for Windows which has the capability of showing non-printing
> characters, and it does not transparently cut convert files without
> informing the user, as Microsoft seems to think they have every right to
> take the liberty to do.
>
> And without putting too fine a point on it, Livecode seems to take the same
> liberties. If I write lf to a file, I expect the file to contain lf and not
> cr! But at least there is a way around it.
>
> Bob S
>
>
>> On Sep 17, 2024, at 4:41 AM, Niggemann, Bernd via use-livecode
>> <use-livecode at lists.runrev.com> wrote:
>>
>> Hi Bob,
>>
>>
>> Actually I think what I need to do is figure out what the original file
>> encoding is, and use that when I write out the export file.
>>
>> I assume that the byte order mark (BOM) is for UTF-8
>>
>> To see the BOM for UTF-8 make a button and a field named "fText"
>>
>> Use this script for the button
>>
>> -------------------------------------------------------------
>> on mouseUp
>> local tPath, tContent, tBom, tCollect
>> answer file "choose"
>> if it is empty then exit mouseUp
>> put it into tPath
>> if the optionKey is down then
>> put url ("binfile:" & tPath) into tContent
>> delete line 2 to -1 of tContent
>> put textEncode(tContent, "UTF-8") into tContent
>> else
>> put url ("file:" & tPath) into tContent
>> delete line 2 to -1 of tContent
>> end if
>> put tContent into field "fText"
>> end mouseUp
>> -------------------------------------------------------------
>>
>> and see if you see the BOM when you hold down the option key when opening
>> the file
>> If you do not use the option key there should be no BOM at the beginning of
>> the text and the text is automatically UTF-8 encoded
>> Apparently "put url ("file:" & tPath)" is also aware of the encoding of the
>> file since it converts it omits the BOM.
>>
>> Kind regards
>> Bernd
>> _______________________________________________
>> 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