有人能告诉我如何在控制台应用程序中编写平方米c# [英] can someone tell me how to write meter squared in console application c#

查看:96
本文介绍了有人能告诉我如何在控制台应用程序中编写平方米c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以告诉我如何在控制台应用程序中编写平方米c#

can someone tell me how to write meter squared in console application c#

推荐答案

首先,您需要为控制台启用Unicode:

First, you need to enable Unicode for console:
System.Console.OutputEncoding = System.Text.Encoding.UTF8;
System.Console.WriteLine("m²");





对于,square字符是Unicode代码点U + 00B2。因此,第二行也可以写成:



For "", "square" character is the Unicode code point U+00B2. So, the second line could also be written as:

System.Console.WriteLine("m\u00b2");





请记住,尽管.NET支持所有作为 System.Text.Encoding 的后代实现的编码,控制台可能不支持所有编码。在回答之前,我确保至少UTF-8和ASCII工作(但ASCII当然不会显示大多数Unicode字符。)



请参阅:

http://msdn.microsoft.com/en-us/library/ system.console.aspx [ ^ ],

http:// msdn。 microsoft.com/en-us/library/system.console.outputencoding.aspx [ ^ ]。



-SA



Remember that even though .NET supports all the encodings implemented as descendants of System.Text.Encoding, console may not support them all. Before answering, I made sure that at least UTF-8 and ASCII work (but ASCII will not show most Unicode characters, of course).

Please see:
http://msdn.microsoft.com/en-us/library/system.console.aspx[^],
http://msdn.microsoft.com/en-us/library/system.console.outputencoding.aspx[^].

—SA


出现在M2(米的平方)的上标2(小2)的Ascii字符id是CHR(253)



您的应用程序是否正确显示它将取决于它e字体,如果字体包含字母。



该字体也依赖于代码页,我希望控制台应用程序依赖于代码页。



因为代码253大于128,这意味着它是一个EXTENDED字符(不是8位字体中使用的原始128个字符的一部分),扩展字符可能并不总是正确显示。



无论您何时使用它,您都可以尝试使用以下内容替换小2字符/符号 - > CHR(253)



或者尝试查找控制台应用程序使用的字体,如果可以更改它,我说这是因为我不是确定是否可以更改控制台应用程序字体。



如果它有效,它可以工作,如果不是你的背面在方块一。
The Ascii character id for the superscript 2 (small 2) which appears in M2 (meter''s squared) is CHR(253)

Wether your application would display it correctly or not would depend on the font and if the font contains the letter.

The font also relies on the codepage too and i expect a console app relies on the codepage.

Because the code 253 is greater than 128 that means it is an EXTENDED character (not part of the original 128 characters used in 8bit fonts) and extended characters may not always display correctly.

Wherever your using it you can always try replacing the the small 2 character/symbol with the following -> CHR(253)

Alternatively try to find which font is being used by your console app and if its possible to change it, i say this because i''m not sure if console app fonts can be changed.

If it works it works and if not your back at square one.


这篇关于有人能告诉我如何在控制台应用程序中编写平方米c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆