Hello Everyone, i come back to you just like last year because i still have an unsolved issue with file names obviously containing a space or something else that i cant see with my eyes.
In a loop for next, i open many files but sometimes it says the file does not exist. Of course the file DOES exist but what is strange is that sometimes ( thought i change nothing) it works ok and sometimes it wont with the same file ! . I have now the problem with a file called "Genèse" when i call this file in the loop and log for its length, it mostly says 6 and suddenly it says 7 !!!!! and then 6 again ! how is it possible that in the same loop it can open the same file several times and suddenly the application seems to add a space or something else in its name ?
I have now the problem with a file called "Genèse" when i call this file in the loop and log for its length, it mostly says 6 and suddenly it says 7 !!!!! and then 6 again ! how is it possible that in the same loop it can open the same file several times and suddenly the application seems to add a space or something else in its name ?
Super! Reproducible bugs are great, even if not 100%.
Log the individual characters of the string too, to work out precisely what is being added.
My first thought is that, in UTF-8, the greater-than-ASCII character "è" would be two bytes rather than just one.
B4X:
Log(FullString("Hello world!!!"))
Log(FullString("Two bees, or not two bees?"))
Log(FullString("Genèse"))
Sub FullString(S As String) As String
Dim sb As StringBuilder
sb.Initialize
Dim L As Int = S.Length
sb.Append(L)
sb.Append(" chars = (")
Dim bc As ByteConverter
Dim C() As Char = bc.ToChars(S)
For I = 0 To L - 1
If I <> 0 Then
sb.Append(", ")
End If
sb.Append(Asc(C(I)))
Next
sb.Append(") = """ & S & """")
Return sb.ToString
End Sub
how is it possible that in the same loop it can open the same file several times and suddenly the application seems to add a space or something else in its name ?
In the loop i ask to look into a big file. According to what he finds in this loop, he opens a file through a variable of course which can be "Genèse" or another one out of 65. This "Genèse" file can tho be opened several times in the SAME loop so sometimes the Genèse length is 6 and all of a sudden its 7!! i can bypass the issue easily, i just tell him if the name of the file contains("Gen")=true then the name of the file is "Genèse" and then it works. But i'm fed up doing that because every time i do that, another file will pop up with exactly the same mistake. the accent has nothing to do with it since i had to bypass the file name "Jean" and then another one named"Colossiens" and another one named "Marc" this is crazy !!. and you wont believe me sometimes i just erase what i call the bypasses and it works ok for all the files !!!! and the next day it wont !! its a mystery to me. ^^
Super! Reproducible bugs are great, even if not 100%.
Log the individual characters of the string too, to work out precisely what is being added.
My first thought is that, in UTF-8, the greater-than-ASCII character "è" would be two bytes rather than just one.
B4X:
Log(FullString("Hello world!!!"))
Log(FullString("Two bees, or not two bees?"))
Log(FullString("Genèse"))
Sub FullString(S As String) As String
Dim sb As StringBuilder
sb.Initialize
Dim L As Int = S.Length
sb.Append(L)
sb.Append(" chars = (")
Dim bc As ByteConverter
Dim C() As Char = bc.ToChars(S)
For I = 0 To L - 1
If I <> 0 Then
sb.Append(", ")
End If
sb.Append(Asc(C(I)))
Next
sb.Append(") = """ & S & """")
Return sb.ToString
End Sub
Thank you Emexes you were great help with you code. it helped me find out that the added char on 1st position was 65279. I dont know why this char is added from time to time for the same file but all i had to do is replace it by an empty character. ? I posted my code and the logs but were not issued, i probably did something wrong. Thanks a lot
Thank you Emexes you were great help with you code. it helped me find out that the added char on 1st position was 65279. I dont know why this char is added from time to time for the same file but all i had to do is replace it by an empty character.
which I vaguely remember is added by Windows Notepad (and presumably other editors) at the beginning of files saved as Unicode (or perhaps only 16-bit and 32-bit Unicode - UTF-8 is pretty clear on byte order).