tfussell / xlnt

:bar_chart: Cross-platform user-friendly xlsx library for C++11+
Other
1.5k stars 423 forks source link

EURO SIGN can handled by VS2015. #43

Closed xpol closed 8 years ago

xpol commented 8 years ago

Tthe EURO SIGN at https://github.com/tfussell/xlnt/blob/master/source/styles/number_format.cpp#L767 not handled by Visual Studio 2015:

1> number_format.cpp 1>D:\Workspace\xlnt\source\styles\number_format.cpp : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss 1>D:\Workspace\xlnt\source\styles\number_format.cpp(767): error C2001: newline in constant 1>D:\Workspace\xlnt\source\styles\number_format.cpp(768): error C2143: syntax error: missing ';' before '}'

I know that is MS' fault.

Can we use escape sequance \xE2\x82\xAC, something like:


const std::string EURO_SIGN{ "\xE2\x82\xAC" };
const std::string EURO_LOCALE{ "$\xE2\x82\xAC-407" };

...

        else if (format.has_locale && format.locale == EURO_LOCALE)
        {
            result += EURO_SIGN;
        }
tfussell commented 8 years ago

I've spent a little time researching this issue. It seems you should be able to set the encoding of this specific file by opening it in VS, selecting File->Advanced save options and selecting Unicode 65001 code page. I'm not sure why I don't see this warning. Maybe you have a different locale setup on your version of Windows? If this resolves the problem for you, I'll consider adding the UTF8 BOM to the beginning of the file.

xpol commented 8 years ago

But does compilers like gcc clang support UTF-8 BOM?

Thomas Fussell notifications@github.com于2016年5月15日周日 上午4:00写道:

I've spent a little time researching this issue. It seems you should be able to set the encoding of this specific file by opening it in VS, selecting File->Advanced save options and selecting Unicode 65001 code page. I'm not sure why I don't see this warning. Maybe you have a different locale setup on your version of Windows? If this resolves the problem for you, I'll consider adding the UTF8 BOM to the beginning of the file.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/tfussell/xlnt/issues/43#issuecomment-219248507

tfussell commented 8 years ago

It looks like GCC and clang both correctly interpret UTF-8 BOM in source files.

tfussell commented 8 years ago

Commit 760d044f7d8202db0898403f128c0c568257dd38 should take care of this by adding a UTF-8 BOM to number_format.cpp. I'm going to close this issue for now assuming this is fixed. We may revisit this decision in the future. Leave a comment if this doesn't solve your problem xpol.

xpol commented 8 years ago

I have tested on Windows 10 with Chinese locale. It builds successfully. Thank you very much!