Lazy Diary @ Hatena Blog

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

Character Encoding

Java Web3層型アプリケーションにおける文字エンコードの指定箇所

Java Web3層型アプリケーションで文字エンコードを指定しそうな箇所をざっと挙げて図にしてみた。 Java Web3層型アプリケーションにおける文字エンコードの指定箇所 元ファイルは以下: Encodings.drawio · GitHub

Format-Hex can't show non-Latin1 characters in the right pane

Problem Format-Hex can't show non-Latin1 characters in the right pane. It represents the result in Latin-1 encoding even if the option -Encoding is specified. PS C:\tmp> "日本語" | Format-Hex -Encoding UTF8 -Raw 00 01 02 03 04 05 06 07 08 …

単にUTF-16と言ったときのエンディアンネス

Oracle DatabaseのAL16UTF16はUTF-16BE *1。UTF-16LEに対応するのはAL16UTF16LEだが、AL16UTF16LEはDatabase CharactersetやNational Charactersetには指定できない*2。 Javaのクラスファイルフォーマットではchar型の値はUTF-16で表される。クラスファイル…

「外字」とは何か?

あるシステムの設計者に「このシステムでは外字を使いますか?」と質問したとしましょう。そのとき、「はい、使います」と答えたとして、その意味として考えられるものは…… 私用領域のコードポイントにある文字を、正規のデータとして処理する Windowsの日本…

Read from .xlsx in PowerShell (x64) without using Excel

This article shows how to read .xlsx in PowerShell without Excel. In Windows 10 (x64), you will have to do additional work. You have to install Microsoft Access Database Engine 2010 Redistributable (AccessDatabaseEngine_X64.exe) when you u…

常用漢字表を新旧漢字変換の根拠資料に使う場合の制約

文化庁の出している常用漢字表 *1 には康煕字典体と常用漢字の対応が記載されている。ただ詳しく調べてみたら、対応の記載自体に以下のようなコーナーケースがあるみたい。 「著しい差異のないものは省」かれているので「頬⇄頰」のような対応は記載がない。 …

康煕字典体から常用漢字へ変換するコマンドレット

変換対照の文字は、文化庁 常用漢字表*1で康煕字典体が示されているものを対照とした。常用漢字表のPDFの内容をテキストファイルへダンプし、以下のスクリプトで常用漢字とカッコ書きの康煕字典体とのペアを抽出した*2。 > Get-Content .\常用漢字表.txt | W…

How to separate a string into codepoint-wise characters with PowerShell

Context: You have a Unicode string that contain non-ASCII characters as well as ASCII characters. You want to separate that string into characters. Problem: If you split the string with the code below: $TemporaryArray = $InputString -split…

How to extract non-MS932 (Shift_JIS) compliant characters from string

function Get-NonMS932CompliantCharacter { Param( [Parameter(ValueFromPipeline=$true,Mandatory=$true)] [string] $TargetString ) process { $TargetStringBytes = [Text.Encoding]::UTF32.GetBytes($TargetString); for ($i=0; $i -lt $TargetStringBy…

java.text.BreakIteratorによる文字数(grapheme)カウント

JIS X 0213など、シフトJISやマイクロソフト コードページ932以外の文字をプログラム上で紙に印刷する場合には、入力された文字列を枠内に確実に収めるため、文字数を正しくカウントする必要があります。 JIS X 0213では複数のコードポイントで1文字を表す文…