New topic: 

Convert Encoding problem on Mac (but works on Windows!)

<http://forums.realsoftware.com/viewtopic.php?t=37808>

         Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic          Author  
Message        Sasha_yu          Post subject: Convert Encoding problem on Mac 
(but works on Windows!)Posted: Thu Feb 24, 2011 6:48 am                         
Joined: Thu Feb 24, 2011 6:02 am
Posts: 1                Hi All,

This is my first post here, so I would like to tell that I really appreciate 
everyone's effort and help here.
I must also say that last time I did some serious programming job about 20 
years ago on Atari ST. 
In the meantime, just something simple in Filemaker Pro. So, please keep this 
in mind. Thank you.

Now, let's back to my problem. I have some really simple App, with 
TaxtArea1.text, and 3 buttons.
With first button, user can choose text file, and in most cases it will be 
Windows CP-1250 (Central European) file.
Code I used for this (just important part):
Code:  t=TextInputStream.Open(ff)
  t.Encoding=Encodings.WindowsLatin2
  TextArea1.text=t.ReadAll
  t.Close
At this stage, all Central European characters are recognized and displayed 
proper way in TextArea1.

Second button is doing some manipulation with text itself, nothing special 
(removing empty lines, number format conversions, etc), and finally it converts 
text to UTF8, because I need target file in that format.
Code:  s=ConvertEncoding(TextArea1.text,Encodings.UTF8)
  TextArea1.text = s
Dummy, but doesn't matter, I made this unnecessary steps to trace what is going 
on.
Anyway, text is converted to UTF8, and all Central European characters are 
still good.

Finally, third button is Save button, and it should save TXT file.
Code:  Dim f As FolderItem
  Dim fileStream as TextOutputStream
  Dim output as String = ReplaceLineEndings( TextArea1.Text, EndOfLine )
  f=GetSaveFolderItem(output,"Test.txt")
  If f <> Nil then
  fileStream=TextOutputStream.Create(f)
  fileStream.WriteLine output
  fileStream.Close
  MsgBox "File saved"
  End if
Result is Test.txt file.

Problem is: Compiled EXE for Windows works good, all characters in final 
Test.txt file look goog even in Notepad, and file is UTF8 format (tested).
However, on Mac version, all Central European characters are lost. Just to have 
a better picture, I will give a couple examples: Instead of "Å¡" I have 
"≈°", instead of "ž" I have "≈æ", etc. (everything without quotes, of 
course)
More interesting, when I open the same file (created on Mac, with wrong 
characters) on Windows, everything is fine (except line endings, but that's not 
important). So, I can open that file in Notepad, save it without any change as 
a Test2.txt, for example, open it again on Mac, and file is now good.

What I'm doing wrong?
I need this to work on Mac without going to Windows.

p.s. Sorry if I made some mistakes in English, I'm not a native Enslish 
speaker. Thank you.   
                             Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to