+28

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🇮🇳

3659 Answers

New Answer

+12

\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

+19

Thanks everyone for Answering 🙏💐😊💐🙏

+7

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);

+6

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.

+6

✳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.

+6

~ 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.

+6

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

+5

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

+5

Is there UTF-32? UTF-64?

+3

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.

+2

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

+1

David Carroll Thank you for the quick action.

+1

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

0

yes i want

0

Hy sir

0

am still getting tones of notifications

0

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