将具有非ISO字符的文件从Visual C ++移植到Linux无法按预期工作 [英] Porting files with non ISO characters from Visual C++ to Linux does not work as expected

查看:63
本文介绍了将具有非ISO字符的文件从Visual C ++移植到Linux无法按预期工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很熟悉有预先保存的选项,我可以选择带或不带BOM(签名)的utf8。我不担心 不同的换行 对于Linux和Windows,在我看来工作正常。我的意思是gcc编译器可以处理它。 
如果我转移cp1250编码,我的程序无法处理某些cp1250 字符。所以我必须将它们转换为utf-8格式。问题是,如果我将它们转换为没有BOM的utf8,它将无法在Visual C ++端工作,而Linux端则为
,它们必须是 没有BOM的UTF-8。即使是为了编译,我只需要复制并粘贴在Nodepad ++上就可以重新复制非ISO字符的文件。 即使我在Linux上编译所有程序,问题依然存在,当将一个带有非ISO字符的参数
传输到另一个文件时, 字符的编码似乎搞砸了。



我希望有一些自动方式将文件轻松地传输到win32和从Linux返回。到目前为止,我很难做到这一点。



是否有关于此问题的更多信息。一些想法?  


解决方案

您好Pereubu123,


感谢您在此处发布。


>>我希望能够通过一些自动方式将文件轻松地传输到win32并从win32传输回Linux。到目前为止,我很难做到这一点。



是否有关于此问题的更多信息。一些想法?


在vs中使用c ++编译器,  Unicode可以通过以下编码输入到源代码文件中:




  • UTF-16小端,带或不带字节顺序标记(BOM)



  • 带或不带BOM的UTF-16大端



  • 带BOM的UTF-8




您可以尝试使用UTF-16 ,Win32 Platform SDK提供了几个API来转换这两种编码:

MultiByteToWideChar
,可用于将UTF-8转换为UTF- 16,

WideCharToMultiByte
,可以用于相反的转换。


有关详细信息,请参阅此示例代码下方。


https://code.msdn.microsoft .com / windowsapps / C-UTF-8-Conversion-Helpers-22c0a664


希望这可以为您提供帮助。


最诚挚的问候,


Sera Yu




I am familiar that there is Advance Saved Options where I could select utf8 with or without BOM (signature). I do not worry about  the different line feed  for Linux and windows, it seems to me that works fine. I mean gcc compiler can handle that.  If I transfer cp1250 encoding, my program could not handle some of the cp1250  characters. So I have to convert them to utf-8 format. The problem is that if I convert them to utf8 without BOM, it will not work on Visual C++ side, while Linux side they have to be  UTF-8 without BOM. Even in order to compile I have to recopied files with non ISO characters by simply copy and paste on Nodepad++.  Even when I compile all programs on Linux, the problem stays that when transfer one parameter with non ISO characters to another file, the  encoding of characters seems to be messed up.

I want to have some automated way to transfer files easily to and from win32 to Linux and back. So far I had very hard time to do that.

Is there somewhere more info about this problem. Some ideas?  

解决方案

Hi Pereubu123,

thanks for posting here.

>>I want to have some automated way to transfer files easily to and from win32 to Linux and back. So far I had very hard time to do that.

Is there somewhere more info about this problem. Some ideas?

With c++ compiler in vs,  Unicode can be input into a source code file in the following encodings:

  • UTF-16 little endian with or without byte order mark (BOM)

  • UTF-16 big endian with or without BOM

  • UTF-8 with BOM

You could try to use UTF-16 , Win32 Platform SDK offers a couple of API's to convert between these two encodings: MultiByteToWideChar, which can be used to convert from UTF-8 to UTF-16, and WideCharToMultiByte, which can be used for the opposite conversion.

For more information, please refer to this sample code below.

https://code.msdn.microsoft.com/windowsapps/C-UTF-8-Conversion-Helpers-22c0a664

Hope this could be help of you.

Best Regards,

Sera Yu


这篇关于将具有非ISO字符的文件从Visual C ++移植到Linux无法按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆