ADODB.StreamのCharsetプロパティに設定できる値
○Charsetプロパティ
セットできる値は
HKEY_CLASSES_ROOT\MIME\Database\Charset
のサブキー一覧の中から選択できます
TypeプロパティがadTypeText=2の時に機能します
※Charsetを列挙する方法
①PwerShellを使う
PS>get-rsdrive
でhkclがドライブとして認識されているか確認します
一覧に無ければ
下記コマンドでPowerShell ドライブとして登録します
PS>New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
登録を削除するには以下のコマンドを使います
PS>Remove-PSDrive -Name HKCR -PSProvider Registry
HKEY_CLASSES_ROOT\MIME\Database\Charsetのフォルダに移動します
PS>cd hkcr:\MIME\Database\Charset
一覧を表示します
PS>ls または PS>dir または PS>gci
パイプを使って一覧をファイルに出力します
PS>ls | C:\test\Charset.txt
②vbs[WSH]を使う
以下のコードを使う
Const HKEY_CLASSES_ROOT = &H80000000 Const HKEY_CURRENT_USER = &H80000001 Const HKEY_LOCAL_MACHINE = &H80000002 Const HKEY_USERS = &H80000003 Const HKEY_PERFORMANCE_DATA = &H80000004 Const HKEY_CURRENT_CONFIG = &H80000005 Const HKEY_DYN_DATA = &H80000006 Const REG_SZ = 1 Const REG_EXPAND_SZ = 2 Const REG_BINARY = 3 Const REG_DWORD = 4 Const REG_MULTI_SZ = 7 Dim strComputer,hDefKey,strKeyPath strComputer = "." ' Use . for current machine hDefKey = HKEY_CLASSES_ROOT strKeyPath = "MIME\Database\Charset" Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv") oReg.EnumKey hDefKey, strKeyPath, arrSubKeys Dim oFs,oTs Set oFs = CreateObject("Scripting.FileSystemObject") Set oTs = oFs.CreateTextFile(oFs.getParentFolderName(WScript.ScriptFullName) & "\CharsetReg.txt", True) For Each strSubkey In arrSubKeys oTs.WriteLine(strSubkey) Next oTs.Close
得られた一覧は次の通り
ANSI_X3.4-1968 ANSI_X3.4-1986 arabic ascii ASMO-708 Big5 chinese CN-GB cp1256 cp367 cp819 cp852 cp866 csASCII csbig5 csEUCKR csEUCPkdFmtJapanese csGB2312 csISO2022JP csISO2022KR csISO58GB231280 csISOLatin1 csISOLatin2 csISOLatin4 csISOLatin5 csISOLatinArabic csISOLatinCyrillic csISOLatinGreek csISOLatinHebrew csKOI8R csKSC56011987 csShiftJIS csUnicode11UTF7 csWindows31J cyrillic DOS-720 DOS-862 DOS-874 ECMA-114 ECMA-118 ELOT_928 euc-jp euc-kr Extended_UNIX_Code_Packed_Format_for_Japanese GB2312 GBK GB_2312-80 greek greek8 hebrew hz-gb-2312 IBM367 ibm819 ibm852 ibm866 iso-2022-jp iso-2022-kr iso-8859-1 iso-8859-11 iso-8859-2 iso-8859-3 iso-8859-4 iso-8859-5 iso-8859-6 iso-8859-7 iso-8859-8 ISO-8859-8 Visual iso-8859-8-i iso-8859-9 iso-ir-100 iso-ir-101 iso-ir-110 iso-ir-111 iso-ir-126 iso-ir-127 iso-ir-138 iso-ir-144 iso-ir-148 iso-ir-149 iso-ir-58 iso-ir-6 ISO646-US iso8859-1 iso8859-2 ISO_646.irv:1991 iso_8859-1 iso_8859-1:1987 iso_8859-2 iso_8859-2:1987 ISO_8859-4 ISO_8859-4:1988 ISO_8859-5 ISO_8859-5:1988 ISO_8859-6 ISO_8859-6:1987 ISO_8859-7 ISO_8859-7:1987 ISO_8859-8 ISO_8859-8:1988 ISO_8859-9 ISO_8859-9:1989 koi koi8-r koi8-ru korean KSC5601 KSC_5601 ks_c_5601 ks_c_5601-1987 ks_c_5601-1989 l1 l2 l4 l5 latin1 latin2 latin4 latin5 logical ms_Kanji shift-jis shift_jis unicode unicode-1-1-utf-7 unicode-1-1-utf-8 unicode-2-0-utf-8 unicodeFFFE us us-ascii utf-7 utf-8 visual windows-1250 windows-1251 windows-1252 windows-1253 Windows-1254 windows-1255 windows-1256 windows-1257 windows-1258 windows-874 x-ansi x-cp1250 x-cp1251 x-euc x-euc-jp x-ms-cp932 x-sjis x-unicode-2-0-utf-7 x-unicode-2-0-utf-8 x-user-defined x-x-big5 _autodetect _autodetect_all _autodetect_kr _iso-2022-jp$ESC _iso-2022-jp$SIO