微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在c ++中的Linux下使用特殊字符ä,ö,ß?此代码在Windows上运行正常

如何解决如何在c ++中的Linux下使用特殊字符ä,ö,ß?此代码在Windows上运行正常

因此,当我尝试在Linux上输入/输出特殊字符时,会收到一个“ ...”作为响应。 我试图将语言环境设置为“ de_DE.UTF-8”,试图将KDE的Konsole设置为德语,但遗憾的是这并不能解决问题。

我在Kubuntu 20.04上,并且使用VSCode作为我的IDE。

Console screenshot

我的代码

#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

//creating variable to store character in
char character;

int main()
{
    //setlocale(LC_ALL,"de_DE.UTF-8");
    //system("locale");

    // getting the input from user
    cout << "Please enter a character that you would like to kNow the ASCII-Code,Octal value and the Hexadecimal value of: ";
    scanf(" %c",&character);

    // printing the character,ASCII-Code,Octal value and Hexadecimal value
    printf("\nThe ASCII-Code for the Character '%c' is: DEC=%d\n",character,character);
    printf("\nThe Octal value for the Character '%c' is: OCT=%o\n",character);
    printf("\nThe Hexadecimal value for the Character '%c' is: HEX=%x\n\n\n\n",character);

    //not letting Command Prompt close itself
    system("PAUSE");
    return 0;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。