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

DetectEncodingInfo

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

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

フィールド

フィールドサイズx64x86説明
nLangIDDWORD4+0+0検出された言語の識別子。
nCodePageDWORD4+4+4検出されたコードページ番号。
nDocPercentINT4+8+8この候補が文書全体に占める割合(パーセント)。
nConfidenceINT4+12+12検出結果の信頼度(パーセント)。

各言語での定義

#include <windows.h>

// DetectEncodingInfo  (x64 16 / x86 16 バイト)
typedef struct DetectEncodingInfo {
    DWORD nLangID;
    DWORD nCodePage;
    INT nDocPercent;
    INT nConfidence;
} DetectEncodingInfo;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct DetectEncodingInfo
{
    public uint nLangID;
    public uint nCodePage;
    public int nDocPercent;
    public int nConfidence;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure DetectEncodingInfo
    Public nLangID As UInteger
    Public nCodePage As UInteger
    Public nDocPercent As Integer
    Public nConfidence As Integer
End Structure
import ctypes
from ctypes import wintypes

class DetectEncodingInfo(ctypes.Structure):
    _fields_ = [
        ("nLangID", wintypes.DWORD),
        ("nCodePage", wintypes.DWORD),
        ("nDocPercent", ctypes.c_int),
        ("nConfidence", ctypes.c_int),
    ]
#[repr(C)]
pub struct DetectEncodingInfo {
    pub nLangID: u32,
    pub nCodePage: u32,
    pub nDocPercent: i32,
    pub nConfidence: i32,
}
import "golang.org/x/sys/windows"

type DetectEncodingInfo struct {
	nLangID uint32
	nCodePage uint32
	nDocPercent int32
	nConfidence int32
}
type
  DetectEncodingInfo = record
    nLangID: DWORD;
    nCodePage: DWORD;
    nDocPercent: Integer;
    nConfidence: Integer;
  end;
const DetectEncodingInfo = extern struct {
    nLangID: u32,
    nCodePage: u32,
    nDocPercent: i32,
    nConfidence: i32,
};
type
  DetectEncodingInfo {.bycopy.} = object
    nLangID: uint32
    nCodePage: uint32
    nDocPercent: int32
    nConfidence: int32
struct DetectEncodingInfo
{
    uint nLangID;
    uint nCodePage;
    int nDocPercent;
    int nConfidence;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; DetectEncodingInfo サイズ: 16 バイト(x64)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; nLangID : DWORD (+0, 4byte)  st.0 = 値  /  値 = st.0   (lpoke/lpeek も可)
; nCodePage : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; nDocPercent : INT (+8, 4byte)  st.2 = 値  /  値 = st.2   (lpoke/lpeek も可)
; nConfidence : INT (+12, 4byte)  st.3 = 値  /  値 = st.3   (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global DetectEncodingInfo
    #field int nLangID
    #field int nCodePage
    #field int nDocPercent
    #field int nConfidence
#endstruct

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