Line Input with invalid characters
Posted on 2005-03-05
Well, well, well...
Im working on a aplication that needs to read some data from txt files.
But that files are like crap. A lot of invalid characters appears on the file.
So i was trying to treat the code, to show on witch line a invalid character appears.
I could observe that some characters (/ # $ =) i could easily change for a space " ". Thats could allow me to continue reading all the fields without no problem.
But , in some lines appears characters like hearts, diamonds , spades, etc... In that case i did notice that this characters delete one character. (Sorry about bad english). For example when i have a heart on the line, if i use len(string), i could receive a invalide result, like 9, and if i open the edit(msdos), and count collum by collum, i could count 10. So in that case i think i could change the character for 2 spaces " " (one for the invalid character, and another for the character that dissapear).
But my problem is becamming bigger. I dont know what is happenning, but in some lines, if i open on edit(msdos), i cant see any invalid characters, but if i count all characters on that line i receive a len of 96. But on vb, if i use len(string), it returns just 95 characthers. How the hell should i fix that?? I cant see the invalid characther, but its looks like it exists. if i cant have a fixed length for all lines, i cant read the fields like "name", "phone", using mid().
Please someone help me with this. Maybe u guys already have a code that track for invalid characters and fix the problem. If that invalid characters didnt change the lenght of the line, i could fix it easily.
But with this strange things happens i really need some help.