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...
Inside a circle there were added all special chars.
As you see, some chars are still fooling me
In the tablet, special chars are converted to their english counterpart.
I don't use any third party code to read the dxf
look for tag 304, you will find the texts
After getting the strings, I convert them to english chars. So, the various A with accents, are all converted to A.
If in the tablet a character doesn't appear, it is because it is not correctly understood by the code that I posted here. This means that, while you see an A with accent in Autocad, in B4A, with textReader, it is read as a "diamond" simbol or something else.
Then try to use a TextReader on file opened with Windows-1252.: you will meet my problems
I did the massive job of reading the dxf
Of course it is a nightmare.
So fonts are hand defined,done not by me, and for this I haven't the special chars..
Dim PortugueseToEnglish As Map = CreateMap( "Ç":"C", _
"é":"e", _
"â":"a", _
"ã":"a", _
"á":"a", _
"à":"a", _
"ç":"c", _
"ê":"e", _
"Ê":"E", _
"Í":"I", _
"í":"i", _
"Ô":"O", _
"Ã":"A", _
"Â":"A", _
"Á":"A", _
"À":"A", _
"É":"E", _
"ô":"o", _
"õ":"o", _
"Ú":"U", _
"Õ":"O", _
"Ó":"O", _
"ó":"o", _
"ú":"u", _
"ñ":"n", _
"Ñ":"N")
I use an InputStream for reading.
Sub Txr_ReadLineBytes(InFile As InputStream) As Byte()
Dim buffer(1) As Byte
Dim bb As B4XBytesBuilder
bb.Initialize
Do While InFile.BytesAvailable <> 0
InFile.ReadBytes(buffer, 0, 1) 'just checked to ensure at least 1 byte was available
Dim Ch As Byte = buffer(0)
If Ch = 13 Or Ch = 10 Then 'CR, LF
If LineTerminator = 0 Then
LineTerminator = Ch 'whichever we hit first, that's our line terminator
End If
If Ch = LineTerminator Then
Exit 'do
End If
Else
bb.Append(buffer)
End If
Loop
Return bb.ToArray
End Sub
Sub Txr_ReadLine(InFile As InputStream) As String
Dim buffer() As Byte = Txr_ReadLineBytes(InFile)
If buffer.Length = 0 Then Return "" 'bypass needless processing below
Dim bc As ByteConverter
Dim TextLine As String = bc.StringFromBytes(buffer, "UTF-8")
If TextLine.Contains(Chr(65533)) Then 'if Unicode replacement character, then wasn't valid UTF-8
TextLine = bc.StringFromBytes(buffer, "windows-1252")
End If
Return TextLine
End Sub
Sub Process_Globals
Dim LineTerminator As Byte
End Sub
Sub AppStart (Args() As String)
Dim InFile As InputStream = File.OpenInput("e:\dxf", "floorplan.dxf")
LineTerminator = 0 'restart cr/lf line terminator discovery
Dim NumLines As Int = 0
Do While InFile.BytesAvailable <> 0
Dim L As String = Txr_ReadLine(InFile)
NumLines = NumLines + 1
Log(NumLines & TAB & L)
Loop
InFile.Close
End Sub
The remapping is the following
Thanks for reading.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?