2017-02-21 1 views
2

슬래시와 대시를 사용하여 포트리스를 만들려고하고 있으며 매크로 (과도기)를 사용해야합니다. 나는 두 가지 방법을 시도했지만 그들 중 누구도 일하지 못했습니다. 어떤 아이디어로 작동 시키는가? Macron 대신 나는 '?'을 얻는다.C# 콘솔 응용 프로그램의 Macron

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 

namespace kingsdom 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      int n = int.Parse(Console.ReadLine()); 
      string ups = new string ('^', n/2); 
      string midUps = new string('_' ,(n * 2) - (((n/2) * 2) + 4)); 
      string whitespaces = new string(' ', (n * 2) - 2); 
      string downs = new string('_', n/2); 
      string midDowns = new string('\u203E', (n * 2) - (((n/2) * 2) + 4)); 
      Console.WriteLine("{0}{1}{2}{3}{0}{1}{2}", "/", ups, "\\", midUps); 
      for (int i = 0; i < n - 2; i++) 
      { 
       Console.WriteLine("{0}{1}{0}", "|", whitespaces); 
      } 
      Console.WriteLine("{0}{1}{2}{3}{0}{1}{2}", "\\", downs, "/", midDowns); 
     } 
    } 
} 
+0

정확히 무엇이 문제입니까? 귀하의 코드는 제게 잘 작동하는 것 같습니다. – Chris

+0

@Chris Macron 대신에 나는 "?" – VG98

+0

아마도이 글꼴이 해당 문자를 지원하지 않는다는 의미입니다. https://dotnetfiddle.net/DOyG5w를 사용해보십시오 (브라우저에 유니 코드 글꼴이있는 것 같습니다). – Chris

답변

3

콘솔에서 다른 코드 페이지를 사용하여 텍스트를 표시 할 수 있습니다. 이러한 코드 페이지 중 일부가 모든 문자를 올바르게 표시 할 수있는 것은 아닙니다. 예를 들어, 키릴 문자가있는 동유럽 언어를 사용하는 Windows 시스템의 기본값 인 코드 페이지 855를 사용하면 Macron 문자를 표시 할 수 없습니다.

당신은 자신의 메인 함수의 시작 부분에 Console.OutputEncoding를 설정하여 자신의 콘솔 출력에 사용되는 어떤 코드 페이지 정의 할 수 있습니다 : 콘솔이 모든 유니 코드 문자를 표시 할 수 있도록

Console.OutputEncoding = Encoding.Unicode; 

이 그것을 만들 것입니다.

당신은 예를 들어 437 (US)에 대한 같은 특정 코드 페이지를 사용하려면

, 당신은 작성합니다

Console.OutputEncoding = Encoding.GetEncoding(437); 

주를이 곳에서 Encoding.Unicode를 사용하여 적어도 .NET 버전 4.5이 필요하다는.

자세한 내용은 documentation of property Console.OutputEncoding을 참조하십시오.

관련 문제