LoadFromFile and Encoding problems lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- wittbo · 2016-12-16 08:15 Sorry for that topic; I know, that there are many streams about encoding, but I guess, that this might be a (my) special OS X problem. I have a CSV-like textfile, not very complex, which contains mixed numbers and text. Within the text, there are some german Umlaute like ä, ü and so on. When inspecting this file with TextEdit or TextWrangler everything looks correct, all Umlaute appear as expected. But if I import this textfile into a memo field (memo1.lines.loadfromfile (....)), every Umlaut appears with a question mark (?).  I could not find any way with loadfromfile to define some special encoding scheme and, more than that, I don't really know, which conversion could be needed. Hope, someone can help me. -wittbo- ---------------------------------------------------------------------- wp · 2016-12-16 08:32 Since you have German umlauts in the file it is probably encoded with CP1252. Call CP1252ToUTF8 after loading (from unit lconvencoding): Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure LoadToMemo(AFileName: String; AMemo: TMemo);var  sl: TStringList;  s: String;begin  sl := TStringList.Create;  try    sl.LoadfromFile(AFileName);    s := CP1252ToUTF8(sl.Text);    Memo1.Text := s;  finally    sl.Free;  end;end; If the file is not CP1252 you should look at the text editor which you used for testing. I don't know TextEdit or TextWrangler, but NotePad++ shows the encoding in the statusbar. Then you should pick the corresponding conversion function from unit lconvencoding. ---------------------------------------------------------------------- wittbo · 2016-12-16 10:57 Thanks for your answer. TextEdit and TextWrangler (both in the Mac) tell me, that the file encoding should be Western "(Mac OS Roman)". I tried several converters but nothing changed, sometimes I get the paragraph char instead of quotation mark for the Umlauts. Some tips for the right converter? -wittbo- ---------------------------------------------------------------------- jwdietrich · 2016-12-16 11:39 If you don't have access to Windows to run NotePad++ as suggested by @wp you could use a hexadecimal editor (e.g. 0xED for Mac) to inspect the file and to learn about the numeric representations of the Umlauts. With this information you could look up in online references, which character encoding applies. The Wikipedia category Character encoding or its German counterpart Zeichenkodierung are good entry points. This information should help to find the correct converter function. ---------------------------------------------------------------------- wp · 2016-12-16 12:55 Did you try this (in lconvencoding)? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function MacintoshToUTF8(const s: string): string;  // Macintosh, alias Mac OS Roman ---------------------------------------------------------------------- wittbo · 2016-12-16 14:21 The solution seems to be quite close. I made some systematic tests: Taking an example Excel file on a Windows PC and then generated three export files with different encodings:      CSV (Windows)      CSV (Macintosh)      CSV (MS-DOS) After that I moved those files to my Lazarus development system, an iMac. There I tried to find the appropriate encoding routine for each file with the following results:      CSV (Windows)         CP1252ToUTF8         CSV (Macintosh)       no converter found      CSV (MS-DOS)         CP850ToUTF8 So the real problem seems to be, that my lconvencoding unit (s. post from wp) does not contain the needed converter MacintoshToUTF8. @WP: Which lazarus version do you use? My actual version is 1.4.4 -wittbo- ---------------------------------------------------------------------- wittbo · 2016-12-16 14:57 OK, perhaps I found what I was looking for. On searching the internet I found this famous site: https://fossies.org/diffs/lazarus/1.4.4-0_vs_1.6RC2- 0/components/lazutils/lconvencoding.pas-diff.html One can see, that conversion MacintoshToUTF8 came with Lazarus 1.6. So what I have to do is updating my Lazarus installation. -wittbo-