Celsius symbol in RichTextBox - c#

I write windows application using C# and .NET2.0.
In RichTextBox I would like to show Celsius symbol.
How to do it? Is it possible?

Do you mean Celsius symbol as in 37°C? If so you can simply put that character where it should be, I guess:
richTextBox.Text = string.Format("{0}°C", degrees);
If you are looking for character codes (or just want to find character to copy/paste them), you can use the Character Map application in Windows (in Start -> Programs -> Accessories -> System Tools).

Do you mean °C? You get ° from the keyboard as ALT + 0176 on the numeric keypad.

If you are wary of embedding a non-ASCII character in your source code, you could use the following instead:
richTextBox.Text = string.Format("{0}\u00B0C", degrees);
(B0 is the hexadecimal for 176.)

richTextBox1.Text = "°" will display a degree symbol in a rich textbox but I'm pretty sure you want something else. Please rephrase your question if that's the case.

° //html entity.

Related

CZ characters from keyboard Unity

I am working on a word game that can take input from the keyboard. Below is the code to detect the key
foreach(KeyCode kcode in Enum.GetValues(typeof(KeyCode)))
{
if (Input.GetKey(kcode))
Debug.Log("KeyCode down: " + kcode);
}
But this code is not taking input CZ language special characters (ě š č ř ž ý á í é ). I already switched my keyboard to the CZECH version.
Your guidance will be appreciated.
Do not use Input.GetKey for keyboard input. It is meant for reading game controls which don't change when you change the input language. To read text, use Input.inputString instead.
Since this looks like this, I assume that you "type" special characters like so "AltGr + 2" to get ě
So to get this key you need to add those two keys
if(Input.GetKey(KeyCode.AltGr) && Input.GetKey(KeyCode.Alpha2))
Debug.Log("KeyCode down: AltGr & 2 equals ě");
You need to "hardcode" for each letter unique configuration to get all special characters
EDIT
To use it like that Link from a comment - as far as Unity is considered, those buttons should be mapped to numeric alpha keys.
So using Input.GetKey(KeyCode.Alpha2) is equal to ě - but you need to write your own handler for that.

Which passwordchar shows a black dot (•) in a winforms textbox using code? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Which passwordchar shows a black dot (•) in a winforms textbox?
Unicode encoding for string literals in C++11
I want to use code to reveal the password or make it a dot like •
textBoxNewPassword.PasswordChar = (char)0149;
How can I achieve this?
http://blog.billsdon.com/2011/04/dot-password-character-c/ suggests '\u25CF';
Or try copy pasting this •
(not exactly an answer to your question, but still)
You can also use the UseSystemPasswordChar property to select the default password character of the system:
textBoxNewPassword.UseSystemPasswordChar = true;
Often mapped to the dot, and always creating a consistent user experience.
You need to look into using the PasswordBox control and setting the PasswordChar as *.
Example:
textBox1.PasswordChar = '*'; // Set a text box for password input
Wikipedia has a table of similar symbols.
In C#, to make a char literal corresponding to U+2022 (for example) use '\u2022'. (It's also fine to cast an integer literal as you do in your question, (char)8226)
Late addition. The reason why your original approach was unsuccessful, is that the value 149 you had is not a Unicode code point. Instead it comes from Windows-1252, and Windows-1252 is not a subset of Unicode. In Unicode, decimal 149 means the C1 control code "Message Waiting".
You could translate from Windows-1252 with:
textBoxNewPassword.PasswordChar =
Encoding.GetEncoding("Windows-1252").GetString(new byte[] { 149, })[0];
but it is easier to use the Unicode value directly of course.
In newer versions of .NET, you need to call:
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
before you can use something like Encoding.GetEncoding("Windows-1252").
textBoxNewPassword.PasswordChar = '\u25CF';

How to output windows Alt keycodes in a C# console app

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.

Use of MaskedTextBox with text

I'm facing a simple problem that bugs me...
I have a MaskedTextBox and I want the user to be able to enter 3 numbers at the end :
"My Masked Text Box : XXX"
This text will be translated. The problem is, this control uses Microsoft's recipe to validate the input and in this example, the final display will look like this :
"My M_sked Text Box : _"
The letter 'a' is considered like a control caracter instead of a simple text caracter. I can backslash it but when the text is translated I have to do it again and I think it's ridiculous to have to do something like that...
I hope I'm being clear...
Thanks in advance for your help !
The 'a' needs to be quoted as a literal. The Mask should be something like:
My M\asked Text Box : 000
You should use '9' rather than '0' as the placeholder for an optional numerical character.
Of course any other of the characters that match mask options should be 'literal' too.
http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.mask.aspx
After reading the comments I'd like to add another suggestion (you clearly understood about literals -- the problem is your translation.)
Would it be feasible to run the translated text strings through a filter that put literal-quotes in where possible? It's not that nice a solution, because if Microsoft added new control characters it'll break your filter, but I think it would work.

How to show symbols like "Lambda" or "Mu" on labels in desktop application in c#.net

Please tell me how can i show symbols like "lambda" or Mu using c#.net in desktop application. what i think is we may do it using ASCII values and convert.toChar();.. if i am right that please give me link of page where i can get ASCII values of all such a scientific symbols.
Please give me link of any URL which contains list of such a ASCII numbers.
Open the Windows character map (charmap.exe), select a Unicode font (Arial should suffice) and copy the symbols into your source code or resources. It's just characters. Of course, you can also switch to Greek keyboard layout, so you can write the characters directly rather than going the charmap route.
Note that you need to use a Unicode font for the labels. You can use charmap to look up which font has Greek characters.
Please tell me how can i show symbols like "lambda" or Mu using c#.net in desktop application.
You don't have to do anything special. Just use whatever letters you want in either the IDE or in strings in the program. C# treats Greek letters the same as any other letters; they are not special.
what i think is we may do it using ASCII values and convert.toChar();
Hold on, I have a phone call. Oh, it's for you. It's 1968 calling, and they want their character set back. :-)
ASCII proper only has 95 printable characters, and Greek letters are not among them. ASCII was invented for teletypes back in the 1960's; we don't use it anymore. Characters in modern programming environments are represented using Unicode, which provides uniform support for tens of thousands of characters in dozens of alphabets.
if i am right then please give me link of page where i can get ASCII values of all such a scientific symbols.
You can get a list of all the Unicode characters at unicode.org. But like I said, you don't need to. You can just embed the character you want directly in the text. There's no need to resort to clumsy tricks like unicode escapes. (Unless, of course, you are planning on sending your source code to your coworkers using a 1970's era teletype machine.)
C# applications are all Unicode - so there should be no problem assigning Unicode strings to the controls' text, for example:
textBox1.Text = "this is a lambda symbol - λ";
Try this
char c = '\u03BB'; //03BC
System.Console.WriteLine(c.ToString());
does it work for you?

Categories