Encoding trouble (mysterious empty added Row)

The following code is a stripped down version of an actual code used in a project where I have troubles (and I do not know why).
After some minutes, I wanted to know why I have an empty line at the LMistBox start. After I Started to investigate, I watched carefully the loop in the debuger and… and I found the following:

The first pass in the For Loop store an empty ASCII string in One_Line, according to the Debugger. The second pass in the Loop store my text in One_Line and assign to it an UTF-8 encoding. It looks like I found something.

[code] Dim Text_UTF As String
Dim LoopIdx As Integer
Dim LineCnt As Integer
Dim One_Line As String

// Delete the previous contents
LB.DeleteAllRows

// The EndOfLine character is LF on OS X…
Text_UTF = “Simple text, one line only.” + EndOfLine // I have another line here, this one is for the test

// How many lines in the dropped text ?
LineCnt = CountFields(Text_UTF,EndOfLine) - 1

// Scan the Text_UTF contents
For LoopIdx = 0 To LineCnt
// Get a line
One_Line = NthField(Text_UTF,EndOfLine,LoopIdx)

// Add it to the ListBox
LB.AddRow Str(LoopIdx) // *

// To Avoid 1, Infinite Loop…
If UserCancelled Then Exit

Next
[/code]
Notes:

I created a brand new project,
I added a ListBox called LB
I added an Event (Open) in Window1 and place the code there.
I do not have nothing else in the project that I do not even save (what for ?)

Environment:
MacBook Pro 2011-11
OS X 10.9.5
Xojo 2014r2.1
TextEdit (Apple),
Safari (Apple).

Another project is loaded in the IDE (I needed to steal some code from it).

Encoding trouble? Surely not. All of the strings in your code shown are UTF8.

Your error is: NthField is 1-based and LoopIdx is 0 in the first pass and returns an empty string (see the docs).

That is not what the debugger told me:
the empty added Row is ASCII
the filled Row is UTF-8.

BTW: in the shared code, I converted LoopIdx to string to show two lines (rows) are added), but in then original code, I always got Row (0) empty and Row(1) holds my first line from the passed text and its encoding is ASCII.

OK: NthField is 1-based.

msgbox encoding("").internetName

gives US-ASCII

msgbox encoding("a").internetName

gives UTF-8