LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Porting from Microsoft studio VC ++ to Linux (https://www.linuxquestions.org/questions/programming-9/porting-from-microsoft-studio-vc-to-linux-4175611045/)

Pereubu 08-01-2017 08:53 AM

Porting from Microsoft studio VC ++ to Linux
 
How transfer cpp file with const string international characters in C from Microsoft Studio to Linux. Let say that I have a file with international latin1 characters. Let say that I have transferred file to UTF-8 and then to Linux...

Do I need to perform command: dos2unix mzCfile.cpp? On my utf-8 cpp file? Because my file is in UTF-8, do I need this command

I know that in MS VC++ File-Advanced Save with "Line endings" as an option to choose UNIX(LF). When I did it on MS VC++ side, my cpp utf-8 file looks as it is written in only one line? International characters looks good...

What I want is to have file I could do cat command and see string of international charaters as it should be and then compile it and run...

dugan 08-01-2017 08:58 AM

Quote:

Originally Posted by Pereubu (Post 5742642)
Do I need to perform command: dos2unix mzCfile.cpp?

I know that in MS VC++ File-Advanced Save with "Line endings" as an option to choose UNIX(LF). When I did it on MS VC++ side, my cpp utf-8 file looks as it is written in only one line?

On Windows, text files have carriage return characters (\r) as the second last character of each line. Those two operations do the same thing: strip those line-ending carriage return characters out. They have nothing to do with UTF-8 encoding.

The UTF-8 encoded stuff should be left alone because Linux supports UTF-8.

NevemTeve 08-01-2017 12:48 PM

Converting line-ends from CRLF to LF is trivial.
Migrating programs between platforms is not always impossible, but always tricky.
Converting programs from ISO-8859-1 to UTF-8 can be problematic, trivial example:
Code:

fputc (stdout, 'ő'); // works in iso-8859-2
fputc (stdout, 'ő'); // doesn't work in utf8, as it is a two-byte sequence


sundialsvcs 08-02-2017 07:58 AM

... and, so far as I recall, the gcc compiler suite is already savvy about source-code line endings . . .

NevemTeve 08-02-2017 08:37 AM

Encodings, on the other hand, might cause problems with gcc. If the original source is in windows-1252, then I suggest not to convert it right now, instead use gcc with these options: -finput-charset=windows-1252 -fexec-charset=windows-1252


All times are GMT -5. The time now is 03:47 PM.