Win32 API 日本語リファレンス
ホームGlobalization › CHARSETINFO

CHARSETINFO

構造体
サイズx64: 32 バイト / x86: 32 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
ciCharsetDWORD4+0+0文字セット値。SHIFTJIS_CHARSETなどGDIで用いる文字セット識別子。
ciACPDWORD4+4+4この文字セットに対応するANSIコードページ番号。
fsFONTSIGNATURE24+8+8対応Unicodeサブセットとコードページを示すFONTSIGNATURE構造体。

各言語での定義

#include <windows.h>

// FONTSIGNATURE  (x64 24 / x86 24 バイト)
typedef struct FONTSIGNATURE {
    DWORD fsUsb[4];
    DWORD fsCsb[2];
} FONTSIGNATURE;

// CHARSETINFO  (x64 32 / x86 32 バイト)
typedef struct CHARSETINFO {
    DWORD ciCharset;
    DWORD ciACP;
    FONTSIGNATURE fs;
} CHARSETINFO;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct FONTSIGNATURE
{
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] public uint[] fsUsb;
    [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)] public uint[] fsCsb;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct CHARSETINFO
{
    public uint ciCharset;
    public uint ciACP;
    public FONTSIGNATURE fs;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure FONTSIGNATURE
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=4)> Public fsUsb() As UInteger
    <MarshalAs(UnmanagedType.ByValArray, SizeConst:=2)> Public fsCsb() As UInteger
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure CHARSETINFO
    Public ciCharset As UInteger
    Public ciACP As UInteger
    Public fs As FONTSIGNATURE
End Structure
import ctypes
from ctypes import wintypes

class FONTSIGNATURE(ctypes.Structure):
    _fields_ = [
        ("fsUsb", wintypes.DWORD * 4),
        ("fsCsb", wintypes.DWORD * 2),
    ]

class CHARSETINFO(ctypes.Structure):
    _fields_ = [
        ("ciCharset", wintypes.DWORD),
        ("ciACP", wintypes.DWORD),
        ("fs", FONTSIGNATURE),
    ]
#[repr(C)]
pub struct FONTSIGNATURE {
    pub fsUsb: [u32; 4],
    pub fsCsb: [u32; 2],
}

#[repr(C)]
pub struct CHARSETINFO {
    pub ciCharset: u32,
    pub ciACP: u32,
    pub fs: FONTSIGNATURE,
}
import "golang.org/x/sys/windows"

type FONTSIGNATURE struct {
	fsUsb [4]uint32
	fsCsb [2]uint32
}

type CHARSETINFO struct {
	ciCharset uint32
	ciACP uint32
	fs FONTSIGNATURE
}
type
  FONTSIGNATURE = record
    fsUsb: array[0..3] of DWORD;
    fsCsb: array[0..1] of DWORD;
  end;

  CHARSETINFO = record
    ciCharset: DWORD;
    ciACP: DWORD;
    fs: FONTSIGNATURE;
  end;
const FONTSIGNATURE = extern struct {
    fsUsb: [4]u32,
    fsCsb: [2]u32,
};

const CHARSETINFO = extern struct {
    ciCharset: u32,
    ciACP: u32,
    fs: FONTSIGNATURE,
};
type
  FONTSIGNATURE {.bycopy.} = object
    fsUsb: array[4, uint32]
    fsCsb: array[2, uint32]

  CHARSETINFO {.bycopy.} = object
    ciCharset: uint32
    ciACP: uint32
    fs: FONTSIGNATURE
struct FONTSIGNATURE
{
    uint[4] fsUsb;
    uint[2] fsCsb;
}

struct CHARSETINFO
{
    uint ciCharset;
    uint ciACP;
    FONTSIGNATURE fs;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; CHARSETINFO サイズ: 32 バイト(x64)
dim st, 8    ; 4byte整数×8(構造体サイズ 32 / 4 切り上げ)
; ciCharset : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; ciACP : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; fs : FONTSIGNATURE (+8, 24byte)  varptr(st)+8 を基点に操作(24byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global FONTSIGNATURE
    #field int fsUsb 4
    #field int fsCsb 2
#endstruct

#defstruct global CHARSETINFO
    #field int ciCharset
    #field int ciACP
    #field FONTSIGNATURE fs
#endstruct

stdim st, CHARSETINFO        ; NSTRUCT 変数を確保
st->ciCharset = 100
mes "ciCharset=" + st->ciCharset