반응형
개발을 하면서 소프트웨어 버전과 같은 특수한 목적으로 Ascii Code 를 많이들 사용하곤 합니다. 오늘은 Powershell 을 이용하여 Ascii Code 를 알아내는 방법에 대해서 소개하려 합니다
Powershell 에서 문자열을 char 배열로 바꾸기 위해서 ToCharArray() 멤버 함수를 사용합니다. 전체 코드는 아래와 같고~
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$a = "C6" | |
$a_hex = $a.ToCharArray() | % { '{0:X2}' -f [byte][char]$_} | |
$a_hex_reverse = $a_hex[($a_hex.Length-1)..0] | |
Write-host $a_hex_reverse |
위 코드에서 {0:X2} 부분은 두 자리 헥사값을 얻기 위한 과정이고~ [byte][char] 는 Ascii Code 를 얻기 위한 과정입니다.
세 번째 줄은 해도 되고 안 되지만 얻어진 헥사값의 순서를 뒤집기 위한 과정입니다.
다른 스크립트 언어도 그렇지만 Windows 환경에서 Powershell 은 정말 다양한 기능이 있는 것 같고~ Powershell 을 사용하느냐 하지 않느냐에 따라서 생산성이 극단적으로 갈리게 되는 거 같습니다. 많은 분들이 Powershell 을 업무에 적극적으로 활용해 보셨으면 합니다.
반응형
'programming language > powershell' 카테고리의 다른 글
Powershell 대소문자 찍기 Alphabet-Upper, Alphabet-Lower (0) | 2019.10.15 |
---|---|
Powershell switch case regular expression 사용 (0) | 2019.07.14 |
Windows 7 Powershell version update (0) | 2019.04.29 |
Powershell 스크립트 실행 시간 측정 (0) | 2019.04.22 |
Powershell Tuple 사용 방법 System.Tuple .NET Framework class (0) | 2019.04.08 |
Windows Powershell 탐색기에서 미리보기 설정하기 (0) | 2019.03.25 |
Powershell xml parsing (0) | 2019.01.30 |
Powershell 을 사용하여 레지스트리 값 변경하기 (0) | 2018.10.07 |
댓글