[WASTE-list] ASCII line endings

Marco Piovanelli marco.piovanelli at pobox.com
Mon Apr 24 14:09:34 EDT 2006


On Mon, 24 Apr 2006 23:36:15 +0700,
Brother Josef (thykeeper at nerdshack.com) wrote:



>i know little about this myself so please bear with me. I *think* you

>understand me here although i used confusing terms. By default the

>line endings in WASTE are not valid when i use them on my UNIX web

>server so i first convert them, which fixes the problem. Converting

>between contrasting conventions is exactly what i'm talking about.

>thanks for picking up my slack Marco! ;) If we understand each other,

>do you know of the proper method for going about this procedure? i

>see WASTE has a line break callback but i'm not certain how to use

>this or if it's the right way for that matter.


No, I'm afraid the line break callback is not what you want here.
Besides, that callback is no longer supported in version 3.0.

When you hit the return key on a Macintosh keyboard, the OS
generates a CR (ASCII 13), but your UNIX web server expects
a LF (ASCII 10) instead. So my guess is that you simply need
to map CRs to LFs upon saving the text into a file.
Using WEFind/WEPut for this conversion is definitely inefficient.
You'll be better off using a simple loop like this:

void MapCRToLF(char * ioText, ByteCount inTextSize)
{
for (ByteCount index = 0; index < inTextSize; ++index)
{
if (ioText[index] == 13)
{
ioText[index] = 10;
}
}
}

Handle MyExtractUNIXCompatibleText(WEReference inWE)
{
Handle hText = NewHandle(0);

WEStreamRange(0, 0x7fffffff, 'TEXT', 0, hText, inWE);
MapCRToLF(*hText, GetHandleSize(hText));
return hText;
}


Hope this helps,


-- marco

--
It's not the data universe only, it's human conversation.
They want to turn it into a one-way flow that they have entirely
monetized. I look at the collective human mind as a kind of
ecosystem. They want to clear cut it. They want to go into the
rainforest of human thought and mow the thing down.



More information about the WASTE-list mailing list