设置编译器的charset ?

xili 2005-09-14 10:08:51

写程序的时候,
char kk[10] = "你好";

char kk[10] = "\xC4\xE3\xBA\xC3";

效果是一样的.

现在的问题是, 有个德国人写程序,
他写 "gro? 而不是写 "gro\xE1", (那个问号是 \xE1 与 引号 合在一起,被系统看作一个双字节字符 \xE1\x22, 而这个编码并不是一个合法字符,所以显示成问号了.)


这样的代码在中文系统,看着是乱码,编译也不能通过.

怎样可以将vc6编译器的charset 设置成 latin1 呢?
显示乱码没关系, 只要求编译器以单字节模式处理文件,编译成功就好.(原文件在德国人的机器上编译没有问题).


...全文
169 17 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
xili 2006-03-06
  • 打赏
  • 举报
回复
呵呵, 俺没有搜到你说的 win apploc.
fiftymetre 2005-09-24
  • 打赏
  • 举报
回复
偶BS里这个拍5星牛人马屁的家伙。唉哟。怎么都这样啊。。。。。。。
xili 2005-09-22
  • 打赏
  • 举报
回复
抱歉回复迟了. 五颗星的确不同凡响啊.

谢谢各位的指教.
doway 2005-09-16
  • 打赏
  • 举报
回复
五星啊!不是盖的。

楼主加上 #pragma setlocale("deu") 好了。

masterz 2005-09-16
  • 打赏
  • 举报
回复
#include "stdafx.h"
#pragma setlocale("chs")
using namespace std;
int _tmain(int argc, _TCHAR* argv[])

{
cout << "系统" << endl;
return 0;
}
xili 2005-09-16
  • 打赏
  • 举报
回复

>不是有责任,是本来就是啊。
>但问题是单字节流也是跟Locale有关的。

不是吧,编译器在parse 原文件,做词法分析时, 应该是与locale无关的吧.
snowbirdfly 2005-09-14
  • 打赏
  • 举报
回复
第一次见到~~~
这样问题看到也是新鲜~~~
呵,鱼和熊掌不可兼得~~~
xili 2005-09-14
  • 打赏
  • 举报
回复
俺过去试过将俺的 win2k 的区域设置改成 us_english, 没有成功,
或许最终可以成功, 但它的麻烦不是一点两点, 是很麻烦.

俺还是认为,编译器有责任将输入文件只看作单字节流来处理.
doway 2005-09-14
  • 打赏
  • 举报
回复
mark
晨星 2005-09-14
  • 打赏
  • 举报
回复
“修改系统的区域设置应该可以,但那样又不能处理中文了.”
一个系统不太好同时处理两种Locale。
zhouhuahai 2005-09-14
  • 打赏
  • 举报
回复
偶也不会这个问题, 可能找个有关C++的国际化的发布文章可以找到答案
xili 2005-09-14
  • 打赏
  • 举报
回复
修改系统的区域设置应该可以,但那样又不能处理中文了.

应该从编译器来控制比较好.
healer_kx 2005-09-14
  • 打赏
  • 举报
回复
faint,啥问题都有。。。我不会,JSP的charset我倒是会。。。
晨星 2005-09-14
  • 打赏
  • 举报
回复
修改系统的区域设置?
fiftymetre 2005-09-14
  • 打赏
  • 举报
回复
有个软件可以,叫win apploc,这个软件可以设置程序的charset,你可以把你编译器的charset设置成想要的语言
doway 2005-09-14
  • 打赏
  • 举报
回复
e:\mydev>javac
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files
-cp <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-endorseddirs <dirs> Override location of endorsed standards path
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
--------------------------------------------------------------------------
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-version Version information
-help Print a synopsis of standard options
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system

JAVA 在这方面还不错,是吧?:)
晨星 2005-09-14
  • 打赏
  • 举报
回复
“编译器有责任将输入文件只看作单字节流来处理”
不是有责任,是本来就是啊。
但问题是单字节流也是跟Locale有关的。

65,187

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧