C# Button Text Unicode characters - c#

C# doesn't want to put Unicode characters on buttons. If I put \u2129 in the Text attribute of the button, the button displays the \u2129, not the Unicode character, (example - I chose 2129 because I could see it in the font currently active on the machine).
I saw this question before, link text, but the question isn't really answered, just got around. I am working on applications which are going all over the world, and don't want to install all the fonts, more then "don't want", there are that many that I doubt the machine I am working on has sufficient disk space. Our overseas sales agents supply the Unicode character "numbers". Is there another way forward with this?
As an aside, (curiosity), why does it not work?

The issue is:
C# will let you put Unicode in, like button1.Text = "Hello \u2129";, no problem
but the Visual Studio Forms designer will not recognize '\u2129' as anything special. By design.
So just paste in the '℩' in the Properties Window or use code.

Change the "Font" of the button to the "Font" (From google:Arial Unicode MS) which supports "u2129". It may help you

have you tried entering the characters manually? also, have you tried using a literal string with #"blahblahblah" ?

I was trying to include copyright symbol (\u00a9) in the form title. Using escape characters or changing fonts didn't work for me. I simply copy-pasted the symbol from text editor.

Related

Referencing symbols of a font that don't have a unicode in c#

I'm trying to use an Icon Font inside a Xamarin application. It is actually quite straight forward and i got the font to work.
However it works fine with using Unicode to reference the symols, like this:
Label iconLabel = new Label
{
Text = "\u0078"
};
But i discovered that only a few symbols of this font have a unicode assigned, the other symbols only have a name. That icon font is usually supposed to be used in html where these symbols can be referenced by the name.
If i try to do this in C#: Text = "arrow_down" it won't work, as it only displays the plain text.
Is there a way this could work with the names of the symbols or maybe a way to automatically add unicodes to every symbol in this font?
I ended up using the fantastic tool fontello and uploaded the open source icon font, selected all the symbols from it and downloaded it again - which generated new unicodes for every single symbol and i got it to work like a charm now. (Additionally fontello generates a great spreadsheet showing every code for every symbol).
In the end i guess this is the smartest way to work around this - if you need to access symbols from a font via unicode but the font isn't laid-out for this, use a tool like fontello to generate your own.

Failed to create a 'Windows.UI.Xaml.Controls.Primitives.PlacementMode' from the text '鼠标'

Hey,I am just a new developer of windows 8 store app. Here is a question I met,even through I had tried my best to search the answers. But I can't find the solution.I hope there is someone could help me.
I just wanted to develop a test app on windows 8,but when I open the file "StandardStyle.xaml" which in the floder Common.The Visual Studio report the error:"Failed to create a 'Windows.UI.Xaml.Controls.Primitives.PlacementMode' from the text '鼠标'".
I am a chinese,so the text is chinese.
In "StandardStyle.xaml", replace :
<ToolTipService.Placement>鼠标</ToolTipService.Placement>
With :
<ToolTipService.Placement>Mouse</ToolTipService.Placement>
ToolTipService.Placement can only be Bottom, Left, Mouse, Right or Top. It shouldn't have been auto-translated on Microsoft side. I had the same issue in French with the word Souris that I had to manually change to Mouse.
PlacementMode is an enumeration (check out this link http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.primitives.placementmode). The text between the mark-ups is suppose to be replaced by a value. So the only text valid are the one present in the link above. Seems like globalisation is the problem here (translating things it should not).

Pasting clipboard content in webbrowser component

i wrote a small application that will monitor the clipboard and paste text directly in a webbrowser component.
...
DocumentWysiwyg = ClipBoardWebBrowser.Document.DomDocument as IHTMLDocument2;
DocumentWysiwyg.designMode = "On";
...
and when the Clipboard changes, i paste the Clipboard content into the webbrowser using:
ClipBoardWebBrowser.Document.Write(Clipboard.GetText(TextDataFormat.Html));
now, when pasting any copied content from web as html, i get inside the html
span class="Apple-converted-space"> </span
which does not belong to the html i copied from a website.
what are those? and how can i get rid of them?
any help is really appreciated .
here is the html code for google.de as example
http://pastie.org/pastes/3706386/text
how would i make sure that the pasted clipboard is exactly the same as the copied data in the clipboard?
On Mac multiple occurrences of a regular space " " get converted such that they replace every other regular space with a non-breaking space character aka This allows the spaces to still break on every other character, but preserve such ranges of spaces.
The reason for this is because without this trick HTML would compress multiple spaces to a single one. Having only characters would disable line wrapping, because as their name states they would be non-breaking.
In addition to "Apple-converted-space" there was also "Apple-style-span" but that was eliminated from Webkit in 2011: https://www.webkit.org/blog/1737/apple-style-span-is-gone/
So to answer your question: since Webkit is filling the pasteboard you cannot do anything to prevent such behavior.

Unicode characters not showing in System.Windows.Forms.TextBox

These characters show fine when I cut-and-paste them here from the VisualStudio debugger, but both in the debugger, and in the TextBox where I am trying to display this text, it just shows squares.
说明\r\n海流受季风影响,3-9 月份其流向主要向北,流速为2 节,有时达3 节;10 月至次年4 月份其流向南至东南方向,流速为2 节。\r\n注意\r\n附近有火山爆发的危险,航行时严加注意\r\n
I thought that the TextBox supported Unicode text. Any idea how I can get this text to display in my application?
You need to install and use a font which supports those characters. Not all fonts support all characters. the [] box character is the fonts representation of 'unsupported'
The textbox might be using MS Sans Serif by default, so change it to Arial or something else.
I changed from using a TextBox to using a RichTextBox, and now the characters display in the RichTextBox.
I was facing similar problem.
It was problem with reading file properly and not with TextBox control.
StreamReader reader = new StreamReader(inputFilePath, Encoding.Default, true)
Copied from THIS.
Works for me and that too without switching to RichTextBox.
Did you add Application.SetCompatibleTextRenderingDefault(false); to your main.cs file? If not, the unicode characters won't show.
Microsoft Sans-Serif does support unicode characters to my knowledge. Check that you have these lines of code in your main.cs file:
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);

How to put unicode characters on a System.Windows.Forms.Button in C#?

In Visual Studio 2008 in a C# WinForms project, there is a button on a form. In the properties view, the property "Font" is set to "Arial Unicode MS".
What do I need to put into the property "Text", so I get the unicode character \u0D15 displayed on the button?
When I put \u0D15 into the "Text" property, the button displays the six characters "\u0D15" instead of one unicode character.
In the following PDF, you can see the unicode character for \u0D15:
http://unicode.org/charts/PDF/U0D00.pdf
You don't have to escape your unicode characters in strings as C# is inherently unicode. Just put your unicode characters as they are into the string. For example:
button1.Text = "日本";
One possible way is to run "charmap" and copypaste from there or copypaste it from elsewhere.
Just try the following in you C# code:
button.Text = "0x0D15";

Categories

Resources