0

My application for macOS archives emails from email clients and IMAP accounts. One user got an email from a Windows user and archived the email from Mail. My app reads the data directly from the hard disk.

The user has an email with some a nice mojibake:

enter image description here

I can identify a few of the characters:

‰ → ä  ̧ → ü

But I can't figure out whhat the original encoding is. I made myself an encoding table for the characters "ö ä ü ß" and my data is not in that table:

enter image description here

Code:

dim theLeft as string = "ö ä ü ß"
for currentEncoding as integer = 0 to Encodings.Count - 1
 
 dim EncodingInternetName as String = Encodings.Item(currentEncoding).internetName
 
 if EncodingInternetName.IndexOf("iso") = -1 and EncodingInternetName.IndexOf("windows") = -1 then Continue
 dim newString as string = DefineEncoding(theLeft, Encodings.Item(currentEncoding)) '<---convert
 newString = ConvertEncoding(newString, Encodings.UTF8)
 Result.Add(EncodingInternetName + " " + newString)
 
next

Does anyone have an idea what encoding was used for the Mojibake?

asked Jan 20, 2023 at 13:24
2
  • You face a double mojibake case (example in Python for its universal intelligibility): 'ö ä ü ß'.encode( 'cp1252').decode( 'mac-roman').encode( 'utf-8').decode( 'cp1252') returns ˆ ‰ ¸ fl and vice versa: 'ˆ ‰ ¸ fl'.encode( 'cp1252').decode( 'utf-8').encode( 'mac-roman').decode( 'cp1252') -> ö ä ü ß ... Commented Jan 20, 2023 at 15:11
  • Thanks, I was able to adapt that to my language. Commented Jan 21, 2023 at 5:51

1 Answer 1

0
dim theString as String = "ˆ ‰  ̧ fl"
theString = theString.ConvertEncoding(Encodings.WindowsANSI)
theString = theString.DefineEncoding(Encodings.UTF8)
theString = theString.ConvertEncoding(Encodings.MacRoman)
theString = theString.DefineEncoding(Encodings.WindowsANSI)
theString = theString.ConvertEncoding(Encodings.UTF8)
answered Jan 21, 2023 at 5:52
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.