Lazy Diary @ Hatena Blog

PowerShell / Java / miscellaneous things about software development, Tips & Gochas. CC BY-SA 4.0/Apache License 2.0

Entries from 2017-05-01 to 1 month

Who does recommend changeing password periodically and who doesn't

Who recommends changeing password periodically Some say you should change password periodically. PCI DSS version 3.2 8.2.4 Change user passwords/passphrases at least once every 90 days. プライバシーマーク制度 (JIPDEC)(In Japanese) based on…

How to convert from ADIF AAC to another format (ffmpeg and libav can't handle it)

Context: You have some AAC ADIF files and you want to convert them into MP3 (and the like) format. Problem: ffmpeg and libav don’t (and will never) support ADIF AAC files because it is “bad format”. see: https://lists.libav.org/pipermail/f…

You should not pass the result of Get-ChildItem into Get-Content (and the like) directly

Context: You can pass the result of Get-ChildItem into Get-Content directly: PS /home/satob/tmp> Get-ChildItem | Where-Object { $_.Name -like "*.csv" } | ForEach-Object { Get-Content $_ } "a","x" "b","2" ... Problem: You cannot pass the re…

You cannot use -Encoding option with Import-Csv in PowerShell 2.0

Context: You use PowerShell 2.0 (Windows 7 or Windows Server 2008 R2). You want to read CSV file that contain non-ASCII characters. Problem: In PowerShell 2.0, Import-Csv cmdlet doesn’t have -Encoding option. Solution: If you want to read …

Difference of acceptable parameters for -Encoding option

Acceptable parameters for -Encoding option are different for Get-Content, Set-Content, Export-Csv, Import-Csv, and Out-File. # cmdlet Default ASCII UTF-7 UTF-8 UTF-16LE UTF-16BE UTF-32LE UTF-32BE Byte Default OEM String Unknown 1 Get-Conte…

Functional limitation of The Nu Html Checker (v.Nu)

Problem: The Nu Html Checker (v.Nu) is useful HTML validator. It can be used not only from a web browser, but also from command line. But, this validator has some functional limitations (for both web interface and CLI version). v.Nu cannot…

How to write result of ConvertTo-Csv to a file in UTF-8 without BOM

Context: You want to write the result of ConvertTo-Csv in UTF-8 encoding without BOM. e.g. You need a file that can be read by a Java program (Java File API cannot handle BOM in UTF-8 encoded files). UTF-8 in PowerShell, e.g. ConvertTo-Csv…

子の名に使える非漢字 JIS X 0208版

法務省 戸籍統一文字情報のページから、自作のPowerShellコマンドレットGet-KosekiMojiを使って、JIS X 0208の非漢字(0x8140(全角スペース)〜0x84BE(╂))について、法務省の定める「子の名に使える文字」かを調査した。使用したPowerShellスクリプトを…

.NET cannot distinguish Shift_JIS from MS932(Windows-31J)

Context: Japanese character encoding Shift_JIS (シフトJIS) and Microsoft Codepage 932 (a.k.a. MS932, Windows-31J in IANA) are slightly different. For example, full-width cent sign (¢) is 0x8191 in both Shift_JIS and MS932, but it is mappe…

PowerShellで法務省 戸籍統一文字情報のページからあるコードポイントの文字の情報を取得する

(In English: How to get information about a Japanese character from 戸籍統一文字情報 site (managed by The Ministry of Justice (Japan)) with PowerShell) 問題: ある漢字に関する情報(読みや、子の名に使える文字か等)を調べたければ、法務省の戸…

ConvertFrom-String is not available on PowerShell Core Edition

Problem: ConvertFrom-String is not available on PowerShell Core Edition. Reason: It seems by design. According to the source of PowerShell on GitHub, ConvertFrom-String is exported for Desktop Edition, but not exported for Core Edition for…

CharsetEncoder#canEncode() equivalent for PowerShell

Context: You want to test whether a codepoint is valid in a specific character encoding. Problem In .NET, there are no equivalent functions to CharsetEncoder#canEncode() in Java. Solution If you want to test whether a character is valid in…

子の名に使える非漢字

「子の名に使える漢字」は法務省に一覧表があるが、「子の名に使える非漢字」については一覧表のようななものがない。 「あ」や「ア」のような一般的なひらがな・カタカナは当たり前に使えるとして、日本の文字コードの規格であるJIS X 0208およびJIS X 0213…