LineEndings not detected with Split and SplitB

I have a TextArea in which i have Text which is loaded from a mySQL Database.
The Text is stored within the Database in Latin1 and is loaded from the recordset with the Defined Encoding Latin1.
Some chars are ISO8859 encoded, so ii use DecodingFromISO8859MBS to convert the Text. The i write it into the TextArea.

When i now try to Split the Text by lines, Xojo does not detect the delimiter.

I tried it with:
.Split(EndOfLine) // Tried it also with EndOfLine.UNIX, EndOfLine.Windows, …
.Split(Chr(13)) and .Split(Chr(10))
.SplitB(Chr(13)) and .SplitB(Chr(10))

Nothing seems to worky.

Why? :slight_smile:

Here’s the Code i use to create the String for the TextArea:

[code] If data<>Nil Then
If data.RecordCount > 0 Then
ArticleBody = data.Field(“body”).StringValue.DefineEncoding(Encodings.WindowsLatin1)
ArticleBody = ArticleBody.Mid(ArticleBody.InStr("")+6) 'Wir wollen nur den Teil zwischen den
ArticleBody = ArticleBody.Left(ArticleBody.InStr("")) 'HTML Tags und
ArticleBody = RemoveHTMLTagsMBS(ArticleBody)
ArticleBody = DecodingFromQuotedPrintableMBS(ArticleBody) 'Alle Escape-Codierten Zeichen zurück in lesbare Zeichen wandeln
End If
data.Close
End If
End If
End If

ArticleBody = DecodingFromISO8859MBS(ArticleBody)

Return NativeStringMBS(ArticleBody)[/code]

w/o seeing data, I’m just taking a stab in the dark, but try:

theVar = ReplaceLineEndings(theText, EndOfLine).Split(EndOfLine)

and see if that works.

[quote=117299:@Sascha S]I have a TextArea in which i have Text which is loaded from a mySQL Database.
The Text is stored within the Database in Latin1 and is loaded from the recordset with the Defined Encoding Latin1.
Some chars are ISO8859 encoded, so ii use DecodingFromISO8859MBS to convert the Text. The i write it into the TextArea.

When i now try to Split the Text by lines, Xojo does not detect the delimiter.

I tried it with:
.Split(EndOfLine) // Tried it also with EndOfLine.UNIX, EndOfLine.Windows, …
.Split(Chr(13)) and .Split(Chr(10))
.SplitB(Chr(13)) and .SplitB(Chr(10))

Nothing seems to worky.

Why? :slight_smile:

Here’s the Code i use to create the String for the TextArea:

[code] If data<>Nil Then
If data.RecordCount > 0 Then
ArticleBody = data.Field(“body”).StringValue.DefineEncoding(Encodings.WindowsLatin1)
ArticleBody = ArticleBody.Mid(ArticleBody.InStr("")+6) 'Wir wollen nur den Teil zwischen den
ArticleBody = ArticleBody.Left(ArticleBody.InStr("")) 'HTML Tags und
ArticleBody = RemoveHTMLTagsMBS(ArticleBody)
ArticleBody = DecodingFromQuotedPrintableMBS(ArticleBody) 'Alle Escape-Codierten Zeichen zurück in lesbare Zeichen wandeln
End If
data.Close
End If
End If
End If

ArticleBody = DecodingFromISO8859MBS(ArticleBody)

Return NativeStringMBS(ArticleBody)[/code][/quote]

Split on EndOfLine, chr(10) or chr(13) will not work on soft wrapped lines. You may want to use StringWidth or some other method to detect the wrap.

The Lines are not softwrapped. the TextArea shows each line as intended.

[quote=117308:@Jeremy Cowgar]w/o seeing data, I’m just taking a stab in the dark, but try:

theVar = ReplaceLineEndings(theText, EndOfLine).Split(EndOfLine)

and see if that works.[/quote]

Strange, but it works perfectly!
Thank you @Jeremy Cowgar :slight_smile:

[quote=117312:@Sascha S]Strange, but it works perfectly!
Thank you @Jeremy Cowgar :)[/quote]

In your original post, you said you had tried with EnOfLine ? ? ?

[quote=117312:@Sascha S]Strange, but it works perfectly!
Thank you @Jeremy Cowgar :)[/quote]

ReplaceLineEndings takes the text passed and standardizes ANY line ending in the text to the line ending you pass. The method call looks silly, a lot of people ask “What does that accomplish” but it does a lot. So, the initial call standardizes the line endings to EndOfLine which is whatever the standard line ending is on the executing operating system. You then split by that line ending in the .Split() call.

Exactly :smiley:

Again, strange but true :slight_smile:

[quote=117299:@Sascha S]I have a TextArea in which i have Text which is loaded from a mySQL Database.
The Text is stored within the Database in Latin1 and is loaded from the recordset with the Defined Encoding Latin1.
Some chars are ISO8859 encoded, so ii use DecodingFromISO8859MBS to convert the Text. The i write it into the TextArea.

When i now try to Split the Text by lines, Xojo does not detect the delimiter.[/quote]

I think there is a catch here. Your source is not a TextField being typed on a system. Your source is text in a DB. Let’s suppose you make a software with 2 clients, one Windows and another Mac. Your DB should have mixed contents. This way, maybe you should normalize the text before writing (my prefered is EndOfLine.UNIX) and decode it to the current system before using it in a UI.