LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-15-2014, 10:51 AM   #1
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
What encoding do you use for your sources?


Hi.

From some time now, I've been doing multiplatform programming using Qt/C++. My IDE of choice is qtcreator, though I don't feel particularly tied to it since I don't use the UI creator part, whatever that was called.

I've been using utf-8 for quite a few years in Linux, which is my primary (and almost-only) platform.

My locale is es_ES@UTF-8.

The problem is that some of my customers like working in Xp, which means problems when it comes to utf-8 in any languages that's not plain English.

I discovered it the hard way, and now I am in a situation where I have to go converting the encoding of the source files every now and then between utf-8 and iso-8859-15, and then back, which can be quite tedious.

How do people handle this kind of stuff? It seems a trivial thing but I can't find anything about this, and after more than one year of developing this way it has become quite time consuming, even with automation scripts, besides it's also error prone.

Thanks for any idea or insight into the issue
 
Old 04-15-2014, 11:50 AM   #2
mina86
Member
 
Registered: Aug 2008
Distribution: Debian
Posts: 517

Rep: Reputation: 229Reputation: 229Reputation: 229
You could play around with BOM but it has it's own set of problems.
 
Old 04-15-2014, 12:19 PM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
For sources usually I use the standard ASCII char set, nothing more. I do not care about any language specific characters, just replace them with a "normal" one. There is no way to avoid problems (caused by those chars).
(I build softwares for almost 20 years, containing parts in spanish, hungarian, german, swedish..., and using java, c, c++, scripts and other languages, on windows/solaris/linux. There is no other way but removing strange chars)
 
Old 04-15-2014, 03:09 PM   #4
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Original Poster
Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Well, in the sources, at some point you will need to write a string or something that will end in the interface.

Intentionally exposing typos to the final users is not something I am willing to do. I'd rather continue this maintenance burden that I have right now or implement something myself when/if I get to the point where I can't stand this anymore.

It just seems odd to me that by now there's no sane way to handle this...

In any case, thanks for the pointer.
 
Old 04-15-2014, 03:14 PM   #5
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Original Poster
Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by mina86 View Post
You could play around with BOM but it has it's own set of problems.
I am not sure how this can help me, care to elaborate?

Or maybe you didn't understand my problem. The issue is with the encoding of the source files. If I save then as utd8 and then compile them the strings won't show properly when you run the .exe in xp. If the source files are saved with iso-8859-15 then the resulting binary works as intended.

Thanks.
 
Old 04-16-2014, 06:33 AM   #6
mina86
Member
 
Registered: Aug 2008
Distribution: Debian
Posts: 517

Rep: Reputation: 229Reputation: 229Reputation: 229
Quote:
Originally Posted by i92guboj View Post
I am not sure how this can help me, care to elaborate?
If you add UTF-8 BOM to the file some Windows applications should read the file as UTF-8. But like I mentioned, this solution may introduce other problems and it may not work for some other applications.

Quote:
Originally Posted by i92guboj View Post
Well, in the sources, at some point you will need to write a string or something that will end in the interface.
Depending on the language, you can escape Unicode characters with “\u####” or similar sequence though. This would be rather cumbersome to do manually though, so perhaps your editor could assist you with that automatically converting non-ASCII characters in strings to escaped sequence.

Last edited by mina86; 04-16-2014 at 06:37 AM.
 
Old 04-16-2014, 06:39 AM   #7
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Original Poster
Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
That I figured. But it wouldn@t help with binaries, would it?

I am not interested in opening source files in windows. I develop fully in linux. What i want is that when it comes the time to launch the exe in windows I'll be able to see accented characters and euro symbols that are hardcoded in the sources, and not some kind of random crap.
 
Old 04-16-2014, 06:41 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
Quote:
Originally Posted by i92guboj View Post
Well, in the sources, at some point you will need to write a string or something that will end in the interface.
No you must not do that. All the displayed texts should be collected and put into some "external" files and you only need to use indices in the sources.
 
  


Reply

Tags
cpp, encoding, iso-8859-15, qt, utf-8



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
disabling cd sources in apt/sources.list revod_neb Linux - Newbie 4 05-25-2013 12:03 PM
Chinese encoding not encoding in kate linuxmandrake Linux - Software 1 12-12-2010 08:50 AM
Need Recommendation for Debian Etch sources.list ( /etc/apt/sources.list ) forgox Debian 6 05-05-2007 01:57 PM
Ubuntu Sources List! I need some great sources lists! Jengo Linux - Newbie 1 06-24-2005 04:50 PM
Software Sources Manager, how to add installation cd sources after deletion Lakota Mandriva 1 10-23-2003 12:39 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration