Need help in C

I'm stuck at a point where I have printed an sparkling emoji by using UTF - 16 (in code "emoji") , now further I want to add a ASCII character (177) in next line( as showed in code 'char' ) But there is problem after declaring utf-16 ..........in next line the following character is not displayed properly Simply i want to combine "emoji" code following "char" code Please also tell the reason why a character doesn't print with UTF - 16 https://code.sololearn.com/c1A0JHPmfK4F/?ref=app https://code.sololearn.com/cHA1yWu1crw6/?ref=app

9/11/2019 6:30:52 PM

Vinesh Wadhwani🇮🇳

22 Answers

New Answer


\u2592 is a character code you need to use in your emoji code to print your desired character. The decimal value in char code '177' is from the CP437(Code Page 437) which is the character set of IBM PC's. This character set is being used by the compiler for output. In emoji code, we changed the character set to UTF-16 which has different decimal values. Standard ascii values for characters are same in all character sets i.e from. 0 - 127. But different character sets have different ascii values in the extended ASCII i.e from 128 - 255. So 177 in CP437 is equal to 9618 Here is a chart for you which shows the equivalent UTF-8/16 values from different character sets https://www.acc.umu.se/~saasha/charsets/?charset=cp855&charset=cp437


Thanks everyone for Answering 🙏💐😊💐🙏


Ankit Tiwari Yes, <io.h> : header file is used to access _setmode(), a routine that sets stdout to Unicode, defined in the same file. "It enables Unicode UTF-16 in SoloLearn C Playground." This header file only works on windows that's why it won't work now on SL's server as it changes to Linux. Here you learn more about its server - https://www.sololearn.com/post/166812/?ref=app


nAutAxH AhmAd I had figured it out already :) But thanks for mentioning it, will be useful for others. I had initially printed it as wprintf(L"\u9618") then with wprintf("%c", 9618) then finally with wprintf(L"%c", 9618);


~ swim ~ Have you printed without using character literal, like this: wprintf("%c", 9618); If that's the case, then you will see a Chinese character as ✳AsterisK✳ said. You need to use character literal of type wchar_t which is 'L' wprintf(L"%c", 9618); Then you should get the correct output as I got. Or maybe you are not getting correct output because of the reason that you mentioned.


Adi Pratama-Universitas Brawijaya UTF-32 exist for sure. UTF-64 don't think so https://en.m.wikipedia.org/wiki/UTF-32


Vinesh Wadhwani🇮🇳 After some research i came to the same conclusion what nAutAxH AhmAd has already said that chars sets have different values for extended ascii char. But the value 9618 prints a box not exactly it's equivalent in ascii mode.


✳AsterisK✳ Unicode handling in general is quite tricky especially on Windows. It's not only about matching charsets, the fonts needs to support the charsets too.


that looks like a Chinese character in a box ~ swim ~


Is there UTF-32? UTF-64?


Mods please handle this, its spamming alot. Hatsy Rei Kinshuk Vasisht Ace ChillPill [Edit by David Carroll] nAutAxH AhmAd We deactivated the account that had spammed 1,961 messages in this question and almost 3,200 in another question.


This erratic behavior many Compiler do posses Declaring another char variable in middle of your program you cannot 😉


David Carroll Thank you for the quick action.


Simple: deactivate the 🌟 at the bottom of the main message.


Is io.h is a valid header?


yes i want


am still getting tones of notifications


Miquel Andreu Fuster Sancho i did that, and it seem the user is ban


Hy sir


Ĥum chic