C中的土耳其语字符问题 [英] Turkish Character Problem in C

查看:121
本文介绍了C中的土耳其语字符问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我想问您有关C和C ++中的语言问题.

我想获取一些字符并在ms-dos窗口中打印出这些字符.

例如,在土耳其语中,我们有一些特殊字符,例如çüğöı";
我想要并且也需要在代码中使用这些字符.我在互联网上搜索后发现有帮助.信息是,如果您想打印一些特殊字符,我应该

Hi all,I want to ask you about language problem in C and C++.

I want to get some characters and print out that characters in ms-dos window.

For example in Turkish we have some special characters like ''çüğöı'';
I want and also need to use this characters in my code.I searched on internet and found something helpful.The information is that if you want to print some special character I should you

#include <locale.h>

main()
{setlocale("LC_ALL",Turkish);
}


我尝试了一下,看起来像在工作.要使用printf(öğçü...");
打印该代码时,可以使用该代码.
但是当我想通过从用户那里获取信息来使用它时,例如


I tried that and it was look like working.I can use that code when i want to print that code by using printf("öğçü ...");

But when I want to use it by getting information from user for example

printf("\n please say something in Turkish");
// --->> for example seçkin
scanf("%s",input);


当我想像那样打印它时printf("%s",input);

我看不到土耳其语字符ç",因此当我想从用户那里输入内容时,它不起作用...

请帮助我,谢谢...

:confused:如果您看不到土耳其语单词,请单击此处查看我说土耳其语特殊单词的意思

http://www.cromwell-intl.com/turkish/orthography.html [ ^ ]


and when i want to print it like that printf("%s",input);

I cannot see Turkish character ''ç'',so it doesn''t work when I want to take input from user...

Please help me,thank you...

:confused: if you cant see Turkish words click here to see what I mean by saying Turkish special word

http://www.cromwell-intl.com/turkish/orthography.html[^]

推荐答案

这绝对是各种标准竞争者应该做的更好的事情.
现在,请注意以下几点:

1)(也是最烦人的):操作系统,C和C ++语言环境是三种不同的东西,彼此之间并不了解.因此要保持一致(在您的示例中,所有内容都是原始C,所以可以,但是不要假设setlocale 还要设置Windows和C ++语言环境对象)

2)(可能是拼写错误)setlocale(LC_ALL, "Turkish")(请注意您的书写方式)仅适用于C(不适用于C ++ STL语言环境的算法,并且不了解最终的OS设置),并且需要您拥有一个C标准库包含土耳其语"查找表(不太明显),因此请检查setlocale的返回值,如果返回值为NULL,则没有机会(除非使用其他设置重建CRT或下载包含土耳其语"语言环境)

3)如果您在源代码中写入了一些字符串文字,请确保源文件编码与编译器预期的相同(如果将源代码另存为CPxxx MBCS,并且编译器将其读取为UTF8-反之亦然-它将以眼泪!

4)确保OS控制台使用的编码与您的程序中使用的编码相同(从第3点开始下降).
This is definitively something various standard commetee should do better.
Right now, be careful of a number of things:

1) (and most annoying): Operating-system, C and C++ locales are three different things, not aware of each other. So be consistent (in your sample, everything is raw C, so OK, but don''t assume setlocale also sets Windows and the C++ locale objects)

2) (may be a typo) setlocale(LC_ALL, "Turkish") (note how you wrote it) works for C only (not C++ STL locale sensible algorithms, and is not aware of the eventual different OS settings) and requires you have a C standard library that contains the "Turkish" lookup tables(that''s not obvious) so check the return value for setlocale and if it is NULL, you have no chance (unless rebuild the CRT with different settings or downloading an edition that includes the "Turkish" locale)

3) if you write some string literals into your source, make sure the source file encoding is the same as expected from the compiler (if you save your source as CPxxx MBCS and the compiler reads it as UTF8 - or viceversa - it will end in tears!

4) make sure that the encoding used by the OS console is the same you use within your program (that descend form point 3)


谢谢Emilio Garavaglia,我不知道如何解决它,我不是C或C ++的大师=)例如,如何检查OS控制台?

顺便说一句,我在Microsoft Visual Studio 2008和Dev C ++中尝试了我的代码,但是它们都没有用...有人说这个问题是由编译器引起的,您是否同意?

感谢您的关注
Thank you Emilio Garavaglia I dont know how to fix it,Im not master of C or C++ =)For example how can I check that OS console or else?

By the way I tried my code in Microsoft Visual Studio 2008 and Dev C++ they neither worked...Some people say that problem causes because of the compiler program,do you agree?

Thanks for your interest


这篇关于C中的土耳其语字符问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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