I am trying to encrypt a Dutch text file with the following but it fails when hitting certain characters “AALST : Stad In Midden-België”, I’m guessing ‘ë’ is the character not working
Should I be using different encodings? I’m using the MBS code from AESMBS example
When I look at the text file in texted the text looks as above but when I import it into my edit field before encrypting the ë is replaced with a question mark. Dutch seems to be the only issue of the 6 languages I am encrypting
d = DefineEncoding(s,Encodings.ASCII)
tout.writeline encryptAES(d, keycode)
First time trying to encrypt and just jumped on the first MBS example.
I noticed that the special ë doesn’t display in the textfield when I import the text file and that part of my code I use tin.Encoding= Encodings.UTF8
I don’t know if this is your problem, but when you decrypt a string, it won’t have an encoding, so you have to use DefineEncoding to tell Xojo it’s UTF8.
ok I will change from ASCII to UTF8 when encrypting and decrypting but I think the problem isn’t there but when I import to the textfield and the characters are being substituted with the ?
I use
tin = f.openAsTextFile
tin.Encoding= Encodings.UTF8
while tin.eof = false
ts = Trim(tin.readline)
tempwc.append ts
Wend
for i = 0 to tempwc.Ubound
a = a + tempwc(i) + Chr(13)
next i
RawTA.value = a
This is how I import the file and this is what I see in the debugger
Dim f as FolderItem
Dim dlg as OpenDialog
Dim tin as textinputstream
Dim ts, a as String
Redim tempwc(-1)
dlg=New OpenDialog
dlg.initialDirectory = SpecialFolder.Desktop
f=dlg.ShowModalwithin(MainWindow1)
if f <> Nil then
wcnt = 0
tin = f.openAsTextFile
tin.Encoding= Encodings.UTF8
while tin.eof = false
ts = Trim(tin.readline)
sseparator = -1
if ts.IndexOf(Chr(58)) <> -1 then 'test for a colon chr(58):
sseparator = 1
if ts <> "" then
tempwc.append ts
wcnt = wcnt + 1
end if
end if
wend
tin.close
I had 6 docx files which I loaded into Pages and exported as plain text. I thought they were all UTF8 as I loaded them into textedit for some minor editing and saving. Somehow the Dutch translations ended up Mac OS Roman… not even sure how that was possible but as @AlbertoD said the assumption was wrong.
I might have to start a new thread but can you search foreign characters like ë in a Regex search? I have a dictionary that I have been using for years to search plain text matches A-Z but if I try a special character it raises and search error?
Current Search pattern rg.SearchPattern = “[^a-zA-Z0-9{}.,*]”