c - Print ASCII box not working -


i trying print shape filled filled ascii boxes console, output garbage text. here code:

#include <stdio.h>  const char shade_block[] = {     "▒▒██████▒▒\n\      ▒████████▒\n\      ██████████\n\      ▒████████▒\n\      ▒▒██████▒▒\n\     "};  int main() {     printf(shade_block);     return 0; } 

and here output:

ΓûÆΓûÆΓûêΓûêΓûêΓûêΓûêΓûêΓûÆΓûÆ          ΓûÆΓûêΓûêΓûêΓûêΓûêΓûêΓûêΓûêΓûÆ          ΓûêΓûêΓûêΓûêΓûêΓûêΓûêΓûêΓûêΓûê          ΓûÆΓûêΓûêΓûêΓûêΓûêΓûêΓûêΓûêΓûÆ          ΓûÆΓûÆΓûêΓûêΓûêΓûêΓûêΓûêΓûÆΓûÆ 

picture of code, if it's not displaying properly.

picture of code, if it's not displaying properly.

i working in c, codelite ide, windows 10 mingw-32. in advance.

windows console used unicode (utf-16 encoding) display text in console. if pass text console in unicode, via writeconsolew - displayed is. if use ansi version writeconsolea - text converted unicode call multibytetowidechar , first parameter codepage used value returned getconsoleoutputcp. default console used oem code page getoemcp. use ansi encoding (getacp). can call setconsoleoutputcp before print in ansi. , need use specific, hardcoded code page value - same, compiler use when compiled source string "▒▒██████▒▒". when run on same windows, compile code (and if compiler not give warning c4566: character represented universal-character-name '\uxxxx' cannot represented in current code page (n)) - setconsoleoutputcp(getacp()) - worked, ansi code pages can different on different computers - not work on another.

so solution here - use unicode l"▒▒██████▒▒" strings writeconsolew or w functions. if got string in runtime multibyte strings - need before print or call setconsoleoutputcp(cp) cp - code page used in string , use a function output. or (better) first convert string unicode via multibytetowidechar(cp, *) , use w functions output


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -