private Sub Txr_ReadLine As String
#if TEXTR
Return Txr.Readline ' if TEXTR is defined, it uses a global TextReader Txr. of course this is not the case
#else
Dim sb As StringBuilder
sb.Initialize
Dim buffer(1) As Byte
Dim bytesRead As Int
Dim eol As Boolean = False
Dim rigaDecodificata As String
RigaDecodificata=""
Do While Not(eol)
bytesRead = InXr.ReadBytes(buffer, 0, 1) ' global InXr
If bytesRead <= 0 Then ' end of file
eol = True
Else
Dim byteVal As Int = Bit.And(buffer(0), 255)
If byteVal = 10 Then ' Rileva '\n'
Dim rigaBytes() As Byte = sb.ToString.GetBytes("ISO-8859-1")
Dim i As Int
Dim redo As Boolean
redo=False
rigaDecodificata = BytesToString(rigaBytes, 0, rigaBytes.Length, "UTF-8")
For i=0 To rigaDecodificata.Length-1 ' empirical check of decoded line chars
If Asc(rigaDecodificata.CharAt(i))>256 Then
redo=True
Exit
End If
Next
If redo Then
rigaDecodificata = BytesToString(rigaBytes, 0, rigaBytes.Length, "Windows-1252")
End If
eol=True
Else If byteVal <> 13 Then ' Ignora '\r'
sb.Append(Chr(byteVal)) ' Accumula caratteri
End If
End If
Loop
' Decodifica l'ultima riga se esiste
Return rigaDecodificata'DecodificaERispondi(sb, possibileWin1252)
#end if
End Sub