views:

141

answers:

4

Hi, I have an application which is supposed to work on both windows and Mac and is localized in Portuguese, Spanish and German. I have an ini file from where the localized strings are read from. But the ini file doesn't work with same encoding for the files on both platforms. For Windows I have to have the file in ANSI format or else the accented letters in the localized strings get messed up and on the Mac the same file should be in Western( Mac OS) encoding or else the same result. Is there any way I can get a single file to work on both platforms?

Thanks jbsp72

+3  A: 

(1) There is no such thing as the ANSI format. That's an unfortunate term for what on Windows means "the local codepage". In particular, this means that in Europe the interpretation of bytes 128-255 as "ANSI format" will differ between countries. So, I am strongly inclined to argue that it won't even work on your first platform, let alone both.

The solution you will eventually migrate to is Unicode. That works everywhere, with all characters, and the number of a character does not depend on the country or the current date (See introduction of €).

MSalters
A: 

gettext is a widely used framework for translation of applications, websites, etc.

hayalci
+1  A: 

On Mac you can have your localised resources (text files, etc) inside a .lproj folder and the Cocoa libraries will find the version for the user's language. For example English.lproj, Spanish.lproj etc. It's better if you use this system instead of having your own custom localisation mechanisms.

If you're using something other than Cocoa and you need to use your custom localisation stuff for portability reasons, then you can try loading the file specifying the text encoding. On Windows it's usually ISO-8859-1 (also known as Windows Latin 1). Or you can convert your text files to Unicode and read them specifying that it's UTF-8. You're not telling what language or frameworks you are using for this so we can't help you any further without more info.

Chochos
A: 

Welcome to a world of pain. I would also recommend switching to Unicode, it will give you a verifiable basis to start with, and make life easier later on

David Sykes