콘솔에 유니 코드 문자를 쓰는 방법?
콘솔 응용 프로그램에서 ℃
.NET을 사용하는 것과 같은 문자를 작성할 수 있는지 궁금합니다 . 이 문자를 쓰려고하면 콘솔이 물음표를 출력합니다.
출력 인코딩이 ASCII로 설정되었을 수 있습니다. 출력을 보내기 전에 이것을 사용해보십시오 :
Console.OutputEncoding = System.Text.Encoding.UTF8;
( 지원 문서에 대한 MSDN 링크 )
다음은 편리한 콘솔 테스트 앱입니다.
씨#
using System;
using System.Text;
public static class ConsoleOutputTest {
public static void Main() {
Console.OutputEncoding = System.Text.Encoding.UTF8;
for (var i = 0; i <= 1000; i++) {
Console.Write(Strings.ChrW(i));
if (i % 50 == 0) { // break every 50 chars
Console.WriteLine();
}
}
Console.ReadKey();
}
}
VB.NET
imports Microsoft.VisualBasic
imports System
public module ConsoleOutputTest
Sub Main()
Console.OutputEncoding = System.Text.Encoding.UTF8
dim i as integer
for i = 0 to 1000
Console.Write(ChrW(i))
if i mod 50 = 0 'break every 50 chars
Console.WriteLine()
end if
next
Console.ReadKey()
End Sub
end module
선택한 콘솔 글꼴이 특정 문자를 지원하지 않을 수도 있습니다. Windows 도구 모음 메뉴 (C :와 같은 아이콘)를 클릭하고 속성-> 글꼴을 선택하십시오. 다른 글꼴을 사용하여 문자가 올바르게 표시되는지 확인하십시오.
MSDN에서 우아한 솔루션을 찾았습니다.
System.Console.Write('\uXXXX') //XXXX is hex Unicode for character
이 간단한 프로그램은 ℃를 화면에 바로 쓴다.
using System;
public class Test
{
public static void Main()
{
Console.Write('\u2103'); //℃ character code
}
}
Console.OutputEncoding 속성
http://msdn.microsoft.com/library/system.console.outputencoding(v=vs.110).aspx
Note that successfully displaying Unicode characters to the console requires the following:
- The console must use a TrueType font, such as Lucida Console or Consolas, to display characters
Besides Console.OutputEncoding = System.Text.Encoding.UTF8;
for some characters you need to install extra fonts (ie. Chinese).
In Windows 10 first go to Region & language settings and install support for required language:
After that you can go to Command Prompt Proporties (or Defaults if you like) and choose some font that supports your language (like KaiTi in Chinese case):
참고URL : https://stackoverflow.com/questions/5750203/how-to-write-unicode-characters-to-the-console
'Programing' 카테고리의 다른 글
/usr/lib/libstdc++.so.6 : 버전`GLIBCXX_3.4.15 '를 찾을 수 없음 (0) | 2020.07.01 |
---|---|
스칼라 컴파일러가 왜 기본 인수로 오버로드 된 메소드를 허용하지 않습니까? (0) | 2020.07.01 |
Firefox 웹 콘솔이 비활성화 되었습니까? (0) | 2020.07.01 |
메모장이 모두를 능가합니까? (0) | 2020.07.01 |
면도기에서 "Html.BeginForm"을 작성하는 방법 (0) | 2020.07.01 |