#Display non-english characters in console.

116 messages · Page 1 of 1 (latest)

drifting dustBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

safe cosmos
#

What terminal are you using and is it set to use UTF-8 or ASCII? (You need the former)

fading sundial
lament anvil
#

okay then it's powershell or cmd

fading sundial
lament anvil
#

ok

#

show the output

fading sundial
#

but when I enter the cmd myself those characters have no problem displaying

#

alr

lament anvil
#

take a screenshot

fading sundial
lament anvil
#

can you show your code?

fading sundial
#
int main() {
    int input;
    int input2;

    std::cout << "Yüzde hesaplayıcısına hoşgeldin, bir değer gir:  ";
    std::cin >> input;

    std::cout << "\nBaşka bir değer gir: ";
    std::cin >> input2;

    double yuzdesonuc = input / (double)input2 * 100;
    std::cout << input << "/" << input2 << " = " << yuzdesonuc << "%";
}
lament anvil
#

did you set utf-8 in your cmd preferences?

fading sundial
#

nope I don't know how

#

in windows or vs?

lament anvil
#

right click on cmd

lament anvil
fading sundial
lament anvil
#

wait I'll see in mine once

fading sundial
#

problem is with encoding in compiler i think

lament anvil
fading sundial
#

yes problem is not with the cmd itself tho

#

its the compiler

lament anvil
#

oh k

#

how?

#

compiler is alright

fading sundial
#

cause i am able to write those problematic characters in the input section of my code

#

they display with no problem

#

compiler fucks with the characters idk how

lament anvil
#

oh

lament anvil
fading sundial
#

then wot

lament anvil
#

terminal

fading sundial
lament anvil
#

instead put those sentences in variables

fading sundial
#

big L from c++

lament anvil
#

yeah

fading sundial
#

and nothing changed

#

there is a warning about character sets

lament anvil
#

lol

#

use std::wstring

fading sundial
#

Severity Code Description Project File Line Suppression State Details
Error (active) E0415 no suitable constructor exists to convert from "const char [56]" to "std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>" learningcpp C:\Users\admin\source\repos\learningcpp\learningcpp\main.cpp 10

lament anvil
#

did you include the header

#

#include <string>

fading sundial
#

yes

lament anvil
#

use it in this way

fading sundial
#

there is just Y in the console rn

lament anvil
#

show

fading sundial
lament anvil
#

use wcout

fading sundial
#
int main() {
    int input;
    int input2;

    std::wstring sentence1 = L"Yüzde hesaplayıcısına hoşgeldin, bir değer gir:  ";
    std::wstring sentence2 = L"\nBaşka bir değer gir: ";

    std::wcout << sentence1;
    std::cin >> input;

    std::wcout << sentence2;
    std::cin >> input2;

    double yuzdesonuc = input / (double)input2 * 100;
    std::cout << input << "/" << input2 << " = " << yuzdesonuc << "%";
}
lament anvil
#

wcin

fading sundial
#

it won't matter the problem starts in the first wcout

lament anvil
#

wait I'll try

safe cosmos
spring heartBOT
#
Program Output
Y?zde hesaplay?c?s?na ho?geldin, bir de?er gir:  
Ba?ka bir de?er gir:
lament anvil
#

I'm getting

#

same

lament anvil
fading sundial
safe cosmos
fading sundial
#

alr

fading sundial
safe cosmos
#

progress I guess

devout willow
fading sundial
devout willow
#

It is using GCC + UTF8 to display text.

fading sundial
#

I still don't get what is the problem, my cmd is set to utf8 i compile with msvc

#

utf8 part looks the same

devout willow
#

In a Cygwin terminal in Windows it works as expected.

fading sundial
#

so the problem is windows terminal?

devout willow
#

yep

fading sundial
#

any fix or it is what it is?

devout willow
#

or MSVC

#

I used GCC to compile it.

#

I will try with GCC + Windows terminal

#

Is the Windows terminal

#

Compiling with GCC or MSVC works in the Cygwin terminal

fading sundial
#

F the windows terminal

lament anvil
#

use powershell

fading sundial
#

can I direct cout to powershell?

lament anvil
#

compile it using g++

#

in the terminal itself

devout willow
#

powershell terminal also doesn't work

lament anvil
#

oh

fading sundial
#

but why

#

if I use writeconsoleW would it work?

devout willow
#

no

#

the problem is not the code

fading sundial
#

but the salvation might be the code

#

no?

devout willow
#

Nope

#

Unless your code simulates a terminal.

#

Using graphics mode.

fading sundial
#

so is there any way to fix windows terminal or should I change it.

#

and still how can I write those special characters and display them but not output them

devout willow
#

Probably the best option is to use a library for a better terminal.

fading sundial
devout willow
#

or something more simple that supports UTF8

#
fading sundial
#

I get this error when I add _setmode

drifting dustBOT
#

@fading sundial

Please Do Not Delete Posts!

Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.

fading sundial
#

is lucida console included in windows or do I have to download it cause I don't see it in fonts section maybe my windows lacks sum features

devout willow
#

It should be included

fading sundial
#

my win SUCKS

#

is it a problem if I download it from internet

devout willow
#

The Consolas font also works.

#

Probably any font with Unicode and fixed size support should do it,

marble gate
#

Just wanted to say fuck character encoding lol

fading sundial
devout willow
#

I was wrong, there is a way to make it work in Windows terminal only using code: