Just a quick question. For the roman numerals above 3999, we used to represent them using a overline. For representing 4000, we will be using the following:
So, to display this overline, what should I do? Also, please advice me which of the above is right?
Update #1
I saw somewhere that we can use Unicode Characters by using the following code:
Console.OutputEncoding = System.Text.Encoding.Unicode;
Console.WriteLine("H\u0305");
Console.WriteLine("\u0305H");
Console.ReadLine();
After putting this code, I have set my console to use Consolas font at 14pt. I got this output:
I was expecting either of the code to show me a combined version, but no avail.
In the console? You can't. Drawing to the console in such a manner is not possible as the console only supports characters.
One does exist in Unicode (as seen here) but this is merely an overlined space.
Related
I'm learning at a nice pace right now trying to rekindle what I almost forgot in programming. Right now I'm re-reviewing the basics of C# coding and I came across an interesting subject on ascii and unicode. The instructor, who I'm learning from online of course, mentioned you can make symbols with either. So I figured, heck yeah I'll do that. I wanted to make a symbol, in Console while using C# with Visual Studio, that shows a capricorn symbol, followed by a heart, and a gemini symbol. Basically saying I (the Capricorn) love(the heart) my girlfriend (The Gemini) using symbols. I assumed it was unicode. However, when I do try to write the line, I get boxes with question marks on all accounts. Here is my code:
using System;
using System.Text;
class EntryPoint
{
static void Main()
{
Console.InputEncoding = Encoding.UTF8;
Console.OutputEncoding = Encoding.UTF8;
//Changes the input and output of the console's encoding
char theGeminiCharacter = '\u264A';
char theCapricornCharacter = '\u2651';
char theHeartCharacter = '\u2764';
string freeSpace = " ";
//Can't seem to find the right unicode process to make the zodiac signs.
Console.WriteLine(theCapricornCharacter + freeSpace + theHeartCharacter + freeSpace + theGeminiCharacter);
}
}
So, what am I doing wrong here? Is it even supposed to be unicode or is there some other code type? I've heard of Alt+X but I didn't really understand it. Thanks in advance!
Yes. It is answered. I noticed that certain fonts just don't do all of the UTF08 Input/Outputs, This particular one (DejaVu Sans Mono) did indeed work. The issue was just font types. Just not sure how to choose that my question was solved.
I want to display superscript 3 in console application. I've tried the following methods but none of them works.
Console.WriteLine("\xB3");
(from here)
Console.WriteLine("ยณ"); // Copied from charmap.exe and also from Wikipedia
How can I display it?
You need to make sure that the encoding of your console is appropriate for rendering the character that you are trying to output.
The relevant property is Console.OutputEncoding.
See MSDN: Console.OutputEncoding Property
0xB3 is a superscript 3 in Unicode, so you need to select UnicodeEncoding.
See MSDN: UnicodeEncoding Class
This works for me:
Console.OutputEncoding = System.Text.Encoding.Unicode;
Console.Write("2\xB3");
Output:
2ยณ
Am working on Universal Windows application and am reading string and if the string contains smiley characters (For eg. ๐) its not getting displayed.
But when I try to declare it statically, Like
<TextBlock Text="๐" />
Am getting the smiley in my emulator, also when my emulator is running. But when I try to work this out via C#, am getting the value as it is. I can't see the smiley here. Like this,
textBlock.Text = "๐";
Do I need to change any textblock properties so that I may get the smileys?
I would recommend you to have a look at http://www.charbase.com/block/emoticons which provides a good overview of emoticons in unicode. Java and .NET seem to use the same escape mechanisms.
In the case of your smiley \ud83d\ude0a would probably do the trick. Your original format ๐ is html-escaped, not .NET escaped.
I have a problem when inserting a string to database due to some encoding issues.
String source is a external rss feed.
In web browser it looks ok. Even in debugger the text appears to be ok.
If I copy the strong to notedpad, the result is also ok.
But in notepad++ was possible to see that string is using combining characters.
If changing to ansii, both combined appears.
e.g.
รก is displayed as aยด
(In notepad++ is is like having two chars, on over the other. I even can select ... half of the char)
I googled a lot and tried very different approach to this problem.
I really want to find a clever way of convert string with combining diacritics to simple utf8 database compatible ones.
Any help?
Thank you so much!
This should work for you
output.Normalize(NormalizationForm.FormC)
This little test gave 3, 2, 3. The middle string is correctly combining A and it's diacritic into a single UTF-8 character
Console.WriteLine(Encoding.UTF8.GetByteCount(("A\u0302")));
Console.WriteLine(Encoding.UTF8.GetByteCount(("A\u0302").Normalize(NormalizationForm.FormC)));
Console.WriteLine(Encoding.UTF8.GetByteCount(("T\u0302").Normalize(NormalizationForm.FormC)));
My Mac can solve this running the following Command in Terminal:
iconv -f utf-8-mac -t utf-8 inputfile >outputfile
How can I output Windows Alt key codes to the console in a C# console app using Console.WriteLine()?
I would like to output characters such as those used for creating boxes.
I can do so manually in a command prompt by holding alt and typing in the appropriate number such as Alt+205, Alt+187, etc.
Thanks
I suppose the easiest way would be to include them directly in your string literals within your source code:
Console.WriteLine("โโ");
EDIT: I'm sorry - my answer is incorrect. ASCII.GetChars will not work for extended ASCII characters. Thanks to Douglas for correcting me.
I think Douglas's answer is the most direct, but you could also get the character based on the value directly using something like this:
char[] characters = System.Text.Encoding.ASCII.GetChars(new byte[]
{65});
For whatever ASCII code you wanted.