Accented Characters

Ok, I have a strange one here, I have a multi line file that has some accented characters, such as on some lines. I am writing a program that reads and does some things with this file. If I split the text by EndOfLine, it crashes the program on Mac, but not on Windows. If I don’t split by endofline then it doesn’t crash.

Here is the code that causes the crash, again only on Mac, not on Windows:

dim dlg as OpenDialog = new OpenDialog dim f as FolderItem = dlg.ShowModal if f <> nil then dim ti as TextInputStream dim Fulltxt as String ti = TextInputStream.Open(f) ti.Encoding = Encodings.UTF8 Fulltxt = ti.ReadAll FullTxt = FullTxt.ReplaceAll(chr(10),EndOfLine) FullTxt = FullTxt.ReplaceAll(chr(13),EndOfLine) ti.Close dim t() as String = Fulltxt.Split(EndOfLine) dim FinalTxt as String while UBound(t) >= 0 if FinalTxt = "" then FinalTxt = t(0) Else FinalTxt = FinalTxt + t(0) end if wend dim c as new Clipboard c.Text = FinalTxt 'This causes either a continual loop or a crash on Mac, but works on Windows end if

The following code will work just fine:

dim dlg as OpenDialog = new OpenDialog dim f as FolderItem = dlg.ShowModal if f <> nil then dim ti as TextInputStream dim Fulltxt as String ti = TextInputStream.Open(f) ti.Encoding = Encodings.UTF8 dim c as new Clipboard c.Text = ti 'This causes either a continual loop or a crash on Mac, but works on Windows end if

Anyone have any ideas on what might cause this?

Also, the following code causes a crash as well:

dim dlg as OpenDialog = new OpenDialog dim f as FolderItem = dlg.ShowModal if f <> nil then dim ti as TextInputStream dim Fulltxt as String ti = TextInputStream.Open(f) ti.Encoding = Encodings.UTF8 dim t() as String while not ti.EOF t.Append(ti.ReadLine) wend ti.Close dim FinalTxt as String while UBound(t) >= 0 if FinalTxt = "" then FinalTxt = t(0) Else FinalTxt = FinalTxt + t(0) end if wend dim c as new Clipboard c.Text = FinalTxt 'This causes either a continual loop or a crash on Mac, but works on Windows end if

32 or 64 bit?

And is it a crash or an exception?

Also, try c.setText ?

You may want to use http://documentation.xojo.com/index.php/ReplaceLineEndings to unify endOfLIne, instead of your cumbersome replace.