Hi everybody
I am facing a really curious problem.
I’m trying to drag and drop a file from the Finder on a listbox, and then I want to save my filename in the DB.
First, I noticed an encoding error in the DB.
Then, I tried this.
[code]// Drag and drop a file named «Fichier corrigé.pdf», received as an object “obj” by the listbox
dim filename As String = “Fichier corrigé.pdf”
if(filename = obj.folderItem.name) then
MsgBox(“This file already exists”)
end if
[/code]
This message never appears. If I save both filenames in my DB, the one defined as a string is saved «Fichier corrigé.pdf» and the one of the file «Fichier corrige?.pdf». So I thought it was an encoding issue.
When I try this :
if(filename.encoding<>obj.folderitem.name.encoding) then
MsgBox("Encodings are different")
end if
I never get the message, so I can imagine both encodings are the same?!?
What the problem? Any idea?
[quote=134608:@SbastienAngot]Hi everybody
I am facing a really curious problem.
I’m trying to drag and drop a file from the Finder on a listbox, and then I want to save my filename in the DB.
First, I noticed an encoding error in the DB.
Then, I tried this.
[code]// Drag and drop a file named Fichier corrig.pdf, received as an object “obj” by the listbox
dim filename As String = “Fichier corrig.pdf”
if(filename = obj.folderItem.name) then
MsgBox(“This file already exists”)
end if
[/code]
This message never appears. If I save both filenames in my DB, the one defined as a string is saved Fichier corrig.pdf and the one of the file Fichier corrige?.pdf. So I thought it was an encoding issue.
When I try this :
if(filename.encoding<>obj.folderitem.name.encoding) then
MsgBox("Encodings are different")
end if
I never get the message, so I can imagine both encodings are the same?!?
What the problem? Any idea?[/quote]
tried that
if obj.FolderItem.name = "e?e?c?a?u?a?e?i?o?u?.txt" then msgbox "OK"
with Mac and PC I dropped a file named “e?e?c?a?u?a?e?i?o?u?.txt”, no problem it displays OK fine in a msgbox.
DB may not be supporting accents “as is”. That is another problem.
I did that and it never displays “OK”. Here is an example :
[code]dim obj As FolderItem
obj = GetOpenFolderItem(".pdf")
// First example with a file named «Fichier corrigé.pdf»
db_execute(“INSERT INTO myTable (filename) VALUES (”+obj.name.SQLify+"))
// Gives «Fichier corrige?.pdf» in my DB table
// Second example
dim filename As String = “Fichier corrigé.pdf”
db_execute(“INSERT INTO myTable (filename) VALUES (”+filename.SQLify+"))
// Gives «Fichier corrigé.pdf» in my DB table
// Third example
MsgBox(obj.name+" - "+filename)
// Shows «Fichier corrigé.pdf - Fichier corrigé.pdf»
[/code]
When I put a break on the first example, I check obj.name and filename encoding that is defined in UTF8 in both cases.
Is the text correct in the debugger in the first example?
I did another try
dim file As FolderItem
file = GetOpenFolderItem(".pdf")
// First Example
MyTextField.Text = ConvertEncoding(DefineEncoding(file.Name, file.Name.Encoding), Encodings.UTF8)
db_execute("INSERT INTO myTable (filenameColumn) VALUES ("+MyTextField.Text.SQLify+"))
// Gives «Fichier corrige?.pdf» in my DB table
// Second Example
dim filename As String = "Fichier corrigé.pdf"
MyTextField.Text = ConvertEncoding(DefineEncoding(filename, filename.Encoding), Encodings.UTF8)
db_execute("INSERT INTO myTable (filenameColumn) VALUES ("+MyTextField.Text.SQLify+"))
// Gives «Fichier corrigé.pdf» in my DB table
Maybe I found a clue
dim file As FolderItem
file = GetOpenFolderItem(".pdf")
dim filename As String = "Fichier corrig.pdf"
MsgBox(ConvertEncoding(filename+" <> "+file.Name, Encodings.ISOLatin5))
// Shows Fichier corrig.pdf <> Fichier corrige?.pdf
Another clue, in my example with a textField, if I overwrite the «é» character of the filename in the field and then, save in DB, it is saved correctly.
It seems that the «é» is not a real «é»… Really curious thing…
Ok, I’m probably close to the solution :
dim file As FolderItem
file = GetOpenFolderItem(".pdf")
dim filename As String = "Fichier corrig.pdf"
if(file.Name.InStr("")<>0) then MsgBox("file.name contains ")
if(filename.InStr("")<>0) then MsgBox("filename string contains ")
// Only the second MsgBox appears
[quote=135072:@SbastienAngot]Ok, I’m probably close to the solution :
[code]
dim file As FolderItem
file = GetOpenFolderItem(".pdf")
dim filename As String = “Fichier corrig.pdf”
if(file.Name.InStr("")<>0) then MsgBox(“file.name contains “)
if(filename.InStr(””)<>0) then MsgBox("filename string contains ")
// Only the second MsgBox appears
[/code][/quote]
I do not know what to tell you. I tried the code before posting.
You may use encoding ASCII to remove accents in both variables. That will probably solve the comparison problem.