ホーム › Globalization › CPINFO
CPINFO
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| MaxCharSize | DWORD | 4 | +0 | +0 | コードページにおける1文字あたりの最大バイト数。 |
| DefaultChar | BYTE | 2 | +4 | +4 | Unicodeに変換できない文字に使う既定文字(最大2バイト)。 |
| LeadByte | BYTE | 12 | +6 | +6 | DBCSの先行バイト範囲を示す配列。開始/終了の組で最大5組、未使用は0。 |
各言語での定義
#include <windows.h>
// CPINFO (x64 20 / x86 20 バイト)
typedef struct CPINFO {
DWORD MaxCharSize;
BYTE DefaultChar[2];
BYTE LeadByte[12];
} CPINFO;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CPINFO
{
public uint MaxCharSize;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public byte[] DefaultChar;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] public byte[] LeadByte;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CPINFO
Public MaxCharSize As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public DefaultChar() As Byte
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=12)> Public LeadByte() As Byte
End Structureimport ctypes
from ctypes import wintypes
class CPINFO(ctypes.Structure):
_fields_ = [
("MaxCharSize", wintypes.DWORD),
("DefaultChar", ctypes.c_ubyte * 2),
("LeadByte", ctypes.c_ubyte * 12),
]#[repr(C)]
pub struct CPINFO {
pub MaxCharSize: u32,
pub DefaultChar: [u8; 2],
pub LeadByte: [u8; 12],
}import "golang.org/x/sys/windows"
type CPINFO struct {
MaxCharSize uint32
DefaultChar [2]byte
LeadByte [12]byte
}type
CPINFO = record
MaxCharSize: DWORD;
DefaultChar: array[0..1] of Byte;
LeadByte: array[0..11] of Byte;
end;const CPINFO = extern struct {
MaxCharSize: u32,
DefaultChar: [2]u8,
LeadByte: [12]u8,
};type
CPINFO {.bycopy.} = object
MaxCharSize: uint32
DefaultChar: array[2, uint8]
LeadByte: array[12, uint8]struct CPINFO
{
uint MaxCharSize;
ubyte[2] DefaultChar;
ubyte[12] LeadByte;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CPINFO サイズ: 20 バイト(x64)
dim st, 5 ; 4byte整数×5(構造体サイズ 20 / 4 切り上げ)
; MaxCharSize : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; DefaultChar : BYTE (+4, 2byte) varptr(st)+4 を基点に操作(2byte:入れ子/配列)
; LeadByte : BYTE (+6, 12byte) varptr(st)+6 を基点に操作(12byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global CPINFO
#field int MaxCharSize
#field byte DefaultChar 2
#field byte LeadByte 12
#endstruct
stdim st, CPINFO ; NSTRUCT 変数を確保
st->MaxCharSize = 100
mes "MaxCharSize=" + st->MaxCharSize