如何在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 (将#修改为@)