'ANSI'에 해당되는 글 1건

  1. 2009/11/05 [예제] xPlatform X Visual C++ Example: 문자열 길이 측정

다음에 나열된 코드는 xPlatform의 msvcrt 모듈을 활용하여 ANSI, 유니코드 인코딩 아래에서 문자열의 길이를 측정하는 샘플 코드입니다.

 

using System;
using xPlatform;
using xPlatform.x86.msvcrt;

namespace xPlatformSample
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("측정할 문자열을 입력하고 Enter를, 종료하려면 입력없이 Enter를 누르세요.");
                Console.Write(">> ");
                string input = Console.ReadLine();

                if (input.Length < 1)
                    break;

                Console.WriteLine();
                Console.WriteLine("ANSI Length (strlen): {0} Byte(s)", msvcrt.strlen(input));
                Console.WriteLine("Unicode Length (wcslen): {0} Char(s)", msvcrt.wcslen(input));
                Console.WriteLine();
            }
        }
    }
}

 

실행 결과

 

 

xPlatform 다운로드: http://blendxplatform.codeplex.com/

 

xPlatform 활용 예제는 계속 업로드될 예정입니다. xPlatform을 활용하는 예제들 중 필요한 것이 있으면 요청에 따라 예제 코드를 만들어서 공개할 수 있으니 많은 참여 부탁드립니다. :-)

 

크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by Windows Azure MVP 남정현 (rkttu.com)