ホーム › Globalization › ucnv_getSubstChars
ucnv_getSubstChars
関数変換器に設定された代替文字を取得する。
シグネチャ
// icuuc.dll
#include <windows.h>
void ucnv_getSubstChars(
const UConverter* converter,
LPSTR subChars,
CHAR* len,
UErrorCode* err
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| converter | UConverter* | in | 対象のコンバーターへのポインタ。 |
| subChars | LPSTR | in | 現在の置換バイト列を受け取る出力バッファ。 |
| len | CHAR* | inout | 入力時はバッファ容量、出力時は実際の置換バイト長を示すポインタ。 |
| err | UErrorCode* | inout | エラーコードを入出力するポインタ。事前にU_ZERO_ERRORで初期化する。 |
戻り値の型: void
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
void ucnv_getSubstChars(
const UConverter* converter,
LPSTR subChars,
CHAR* len,
UErrorCode* err
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern void ucnv_getSubstChars(
ref IntPtr converter, // UConverter*
[MarshalAs(UnmanagedType.LPStr)] string subChars, // LPSTR
IntPtr len, // CHAR* in/out
ref int err // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Sub ucnv_getSubstChars(
ByRef converter As IntPtr, ' UConverter*
<MarshalAs(UnmanagedType.LPStr)> subChars As String, ' LPSTR
len As IntPtr, ' CHAR* in/out
ByRef err As Integer ' UErrorCode* in/out
)
End Sub' converter : UConverter*
' subChars : LPSTR
' len : CHAR* in/out
' err : UErrorCode* in/out
Declare PtrSafe Sub ucnv_getSubstChars Lib "icuuc" ( _
ByRef converter As LongPtr, _
ByVal subChars As String, _
ByVal len As LongPtr, _
ByRef err As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ucnv_getSubstChars = ctypes.cdll.icuuc.ucnv_getSubstChars
ucnv_getSubstChars.restype = None
ucnv_getSubstChars.argtypes = [
ctypes.c_void_p, # converter : UConverter*
wintypes.LPCSTR, # subChars : LPSTR
ctypes.POINTER(ctypes.c_byte), # len : CHAR* in/out
ctypes.c_void_p, # err : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
ucnv_getSubstChars = Fiddle::Function.new(
lib['ucnv_getSubstChars'],
[
Fiddle::TYPE_VOIDP, # converter : UConverter*
Fiddle::TYPE_VOIDP, # subChars : LPSTR
Fiddle::TYPE_VOIDP, # len : CHAR* in/out
Fiddle::TYPE_VOIDP, # err : UErrorCode* in/out
],
Fiddle::TYPE_VOID, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn ucnv_getSubstChars(
converter: *const isize, // UConverter*
subChars: *mut u8, // LPSTR
len: *mut i8, // CHAR* in/out
err: *mut i32 // UErrorCode* in/out
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void ucnv_getSubstChars(ref IntPtr converter, [MarshalAs(UnmanagedType.LPStr)] string subChars, IntPtr len, ref int err);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ucnv_getSubstChars' -Namespace Win32 -PassThru
# $api::ucnv_getSubstChars(converter, subChars, len, err)#uselib "icuuc.dll"
#func global ucnv_getSubstChars "ucnv_getSubstChars" sptr, sptr, sptr, sptr
; ucnv_getSubstChars varptr(converter), subChars, varptr(len), varptr(err)
; converter : UConverter* -> "sptr"
; subChars : LPSTR -> "sptr"
; len : CHAR* in/out -> "sptr"
; err : UErrorCode* in/out -> "sptr"出力引数:
#uselib "icuuc.dll" #func global ucnv_getSubstChars "ucnv_getSubstChars" var, str, var, var ; ucnv_getSubstChars converter, subChars, len, err ; converter : UConverter* -> "var" ; subChars : LPSTR -> "str" ; len : CHAR* in/out -> "var" ; err : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #func global ucnv_getSubstChars "ucnv_getSubstChars" sptr, str, sptr, sptr ; ucnv_getSubstChars varptr(converter), subChars, varptr(len), varptr(err) ; converter : UConverter* -> "sptr" ; subChars : LPSTR -> "str" ; len : CHAR* in/out -> "sptr" ; err : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void ucnv_getSubstChars(UConverter* converter, LPSTR subChars, CHAR* len, UErrorCode* err) #uselib "icuuc.dll" #func global ucnv_getSubstChars "ucnv_getSubstChars" var, str, var, var ; ucnv_getSubstChars converter, subChars, len, err ; converter : UConverter* -> "var" ; subChars : LPSTR -> "str" ; len : CHAR* in/out -> "var" ; err : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void ucnv_getSubstChars(UConverter* converter, LPSTR subChars, CHAR* len, UErrorCode* err) #uselib "icuuc.dll" #func global ucnv_getSubstChars "ucnv_getSubstChars" intptr, str, intptr, intptr ; ucnv_getSubstChars varptr(converter), subChars, varptr(len), varptr(err) ; converter : UConverter* -> "intptr" ; subChars : LPSTR -> "str" ; len : CHAR* in/out -> "intptr" ; err : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procucnv_getSubstChars = icuuc.NewProc("ucnv_getSubstChars")
)
// converter (UConverter*), subChars (LPSTR), len (CHAR* in/out), err (UErrorCode* in/out)
r1, _, err := procucnv_getSubstChars.Call(
uintptr(converter),
uintptr(unsafe.Pointer(windows.BytePtrFromString(subChars))),
uintptr(len),
uintptr(err),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure ucnv_getSubstChars(
converter: Pointer; // UConverter*
subChars: PAnsiChar; // LPSTR
len: Pointer; // CHAR* in/out
err: Pointer // UErrorCode* in/out
); cdecl;
external 'icuuc.dll' name 'ucnv_getSubstChars';result := DllCall("icuuc\ucnv_getSubstChars"
, "Ptr", converter ; UConverter*
, "AStr", subChars ; LPSTR
, "Ptr", len ; CHAR* in/out
, "Ptr", err ; UErrorCode* in/out
, "Cdecl Int") ; return: void●ucnv_getSubstChars(converter, subChars, len, err) = DLL("icuuc.dll", "int ucnv_getSubstChars(void*, char*, void*, void*)")
# 呼び出し: ucnv_getSubstChars(converter, subChars, len, err)
# converter : UConverter* -> "void*"
# subChars : LPSTR -> "char*"
# len : CHAR* in/out -> "void*"
# err : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "icuuc" fn ucnv_getSubstChars(
converter: [*c]isize, // UConverter*
subChars: [*c]const u8, // LPSTR
len: [*c]i8, // CHAR* in/out
err: [*c]i32 // UErrorCode* in/out
) callconv(.c) void;proc ucnv_getSubstChars(
`converter`: ptr int, # UConverter*
subChars: cstring, # LPSTR
len: ptr int8, # CHAR* in/out
err: ptr int32 # UErrorCode* in/out
) {.importc: "ucnv_getSubstChars", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
void ucnv_getSubstChars(
ptrdiff_t* converter, // UConverter*
const(char)* subChars, // LPSTR
byte* len, // CHAR* in/out
int* err // UErrorCode* in/out
);ccall((:ucnv_getSubstChars, "icuuc.dll"), Cvoid,
(Ptr{Int}, Cstring, Ptr{Int8}, Ptr{Int32}),
converter, subChars, len, err)
# converter : UConverter* -> Ptr{Int}
# subChars : LPSTR -> Cstring
# len : CHAR* in/out -> Ptr{Int8}
# err : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
void ucnv_getSubstChars(
intptr_t* converter,
const char* subChars,
int8_t* len,
int32_t* err);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.ucnv_getSubstChars(converter, subChars, len, err)
-- converter : UConverter*
-- subChars : LPSTR
-- len : CHAR* in/out
-- err : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const ucnv_getSubstChars = lib.func('__cdecl', 'ucnv_getSubstChars', 'void', ['intptr_t *', 'str', 'int8_t *', 'int32_t *']);
// ucnv_getSubstChars(converter, subChars, len, err)
// converter : UConverter* -> 'intptr_t *'
// subChars : LPSTR -> 'str'
// len : CHAR* in/out -> 'int8_t *'
// err : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
ucnv_getSubstChars: { parameters: ["pointer", "buffer", "pointer", "pointer"], result: "void" },
});
// lib.symbols.ucnv_getSubstChars(converter, subChars, len, err)
// converter : UConverter* -> "pointer"
// subChars : LPSTR -> "buffer"
// len : CHAR* in/out -> "pointer"
// err : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void ucnv_getSubstChars(
intptr_t* converter,
const char* subChars,
int8_t* len,
int32_t* err);
C, "icuuc.dll");
// $ffi->ucnv_getSubstChars(converter, subChars, len, err);
// converter : UConverter*
// subChars : LPSTR
// len : CHAR* in/out
// err : UErrorCode* in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Icuuc extends Library {
Icuuc INSTANCE = Native.load("icuuc", Icuuc.class);
void ucnv_getSubstChars(
LongByReference converter, // UConverter*
String subChars, // LPSTR
byte[] len, // CHAR* in/out
IntByReference err // UErrorCode* in/out
);
}@[Link("icuuc")]
lib Libicuuc
fun ucnv_getSubstChars = ucnv_getSubstChars(
converter : LibC::SSizeT*, # UConverter*
subChars : UInt8*, # LPSTR
len : Int8*, # CHAR* in/out
err : Int32* # UErrorCode* in/out
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ucnv_getSubstCharsNative = Void Function(Pointer<IntPtr>, Pointer<Utf8>, Pointer<Int8>, Pointer<Int32>);
typedef ucnv_getSubstCharsDart = void Function(Pointer<IntPtr>, Pointer<Utf8>, Pointer<Int8>, Pointer<Int32>);
final ucnv_getSubstChars = DynamicLibrary.open('icuuc.dll')
.lookupFunction<ucnv_getSubstCharsNative, ucnv_getSubstCharsDart>('ucnv_getSubstChars');
// converter : UConverter* -> Pointer<IntPtr>
// subChars : LPSTR -> Pointer<Utf8>
// len : CHAR* in/out -> Pointer<Int8>
// err : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure ucnv_getSubstChars(
converter: Pointer; // UConverter*
subChars: PAnsiChar; // LPSTR
len: Pointer; // CHAR* in/out
err: Pointer // UErrorCode* in/out
); cdecl;
external 'icuuc.dll' name 'ucnv_getSubstChars';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "ucnv_getSubstChars"
c_ucnv_getSubstChars :: Ptr CIntPtr -> CString -> Ptr Int8 -> Ptr Int32 -> IO ()
-- converter : UConverter* -> Ptr CIntPtr
-- subChars : LPSTR -> CString
-- len : CHAR* in/out -> Ptr Int8
-- err : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let ucnv_getsubstchars =
foreign "ucnv_getSubstChars"
((ptr intptr_t) @-> string @-> (ptr int8_t) @-> (ptr int32_t) @-> returning void)
(* converter : UConverter* -> (ptr intptr_t) *)
(* subChars : LPSTR -> string *)
(* len : CHAR* in/out -> (ptr int8_t) *)
(* err : UErrorCode* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library icuuc (t "icuuc.dll"))
(cffi:use-foreign-library icuuc)
(cffi:defcfun ("ucnv_getSubstChars" ucnv-get-subst-chars :convention :cdecl) :void
(converter :pointer) ; UConverter*
(sub-chars :string) ; LPSTR
(len :pointer) ; CHAR* in/out
(err :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ucnv_getSubstChars = Win32::API::More->new('icuuc',
'void ucnv_getSubstChars(LPVOID converter, LPCSTR subChars, LPVOID len, LPVOID err)');
# my $ret = $ucnv_getSubstChars->Call($converter, $subChars, $len, $err);
# converter : UConverter* -> LPVOID
# subChars : LPSTR -> LPCSTR
# len : CHAR* in/out -> LPVOID
# err : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型