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

ucnv_safeClone

関数
変換器をスタックバッファ上に安全に複製する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

// icuuc.dll
#include <windows.h>

UConverter* ucnv_safeClone(
    const UConverter* cnv,
    void* stackBuffer,
    INT* pBufferSize,
    UErrorCode* status
);

パラメーター

名前方向
cnvUConverter*in
stackBuffervoid*inout
pBufferSizeINT*inout
statusUErrorCode*inout

戻り値の型: UConverter*

各言語での呼び出し定義

// icuuc.dll
#include <windows.h>

UConverter* ucnv_safeClone(
    const UConverter* cnv,
    void* stackBuffer,
    INT* pBufferSize,
    UErrorCode* status
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr ucnv_safeClone(
    ref IntPtr cnv,   // UConverter*
    IntPtr stackBuffer,   // void* in/out
    ref int pBufferSize,   // INT* in/out
    ref int status   // UErrorCode* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucnv_safeClone(
    ByRef cnv As IntPtr,   ' UConverter*
    stackBuffer As IntPtr,   ' void* in/out
    ByRef pBufferSize As Integer,   ' INT* in/out
    ByRef status As Integer   ' UErrorCode* in/out
) As IntPtr
End Function
' cnv : UConverter*
' stackBuffer : void* in/out
' pBufferSize : INT* in/out
' status : UErrorCode* in/out
Declare PtrSafe Function ucnv_safeClone Lib "icuuc" ( _
    ByRef cnv As LongPtr, _
    ByVal stackBuffer As LongPtr, _
    ByRef pBufferSize As Long, _
    ByRef status As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ucnv_safeClone = ctypes.cdll.icuuc.ucnv_safeClone
ucnv_safeClone.restype = ctypes.c_void_p
ucnv_safeClone.argtypes = [
    ctypes.c_void_p,  # cnv : UConverter*
    ctypes.POINTER(None),  # stackBuffer : void* in/out
    ctypes.POINTER(ctypes.c_int),  # pBufferSize : INT* in/out
    ctypes.c_void_p,  # status : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
ucnv_safeClone = Fiddle::Function.new(
  lib['ucnv_safeClone'],
  [
    Fiddle::TYPE_VOIDP,  # cnv : UConverter*
    Fiddle::TYPE_VOIDP,  # stackBuffer : void* in/out
    Fiddle::TYPE_VOIDP,  # pBufferSize : INT* in/out
    Fiddle::TYPE_VOIDP,  # status : UErrorCode* in/out
  ],
  Fiddle::TYPE_VOIDP, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn ucnv_safeClone(
        cnv: *const isize,  // UConverter*
        stackBuffer: *mut (),  // void* in/out
        pBufferSize: *mut i32,  // INT* in/out
        status: *mut i32  // UErrorCode* in/out
    ) -> *mut isize;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr ucnv_safeClone(ref IntPtr cnv, IntPtr stackBuffer, ref int pBufferSize, ref int status);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ucnv_safeClone' -Namespace Win32 -PassThru
# $api::ucnv_safeClone(cnv, stackBuffer, pBufferSize, status)
#uselib "icuuc.dll"
#func global ucnv_safeClone "ucnv_safeClone" sptr, sptr, sptr, sptr
; ucnv_safeClone cnv, stackBuffer, varptr(pBufferSize), status   ; 戻り値は stat
; cnv : UConverter* -> "sptr"
; stackBuffer : void* in/out -> "sptr"
; pBufferSize : INT* in/out -> "sptr"
; status : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "icuuc.dll"
#cfunc global ucnv_safeClone "ucnv_safeClone" int, sptr, var, int
; res = ucnv_safeClone(cnv, stackBuffer, pBufferSize, status)
; cnv : UConverter* -> "int"
; stackBuffer : void* in/out -> "sptr"
; pBufferSize : INT* in/out -> "var"
; status : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; UConverter* ucnv_safeClone(UConverter* cnv, void* stackBuffer, INT* pBufferSize, UErrorCode* status)
#uselib "icuuc.dll"
#cfunc global ucnv_safeClone "ucnv_safeClone" int, intptr, var, int
; res = ucnv_safeClone(cnv, stackBuffer, pBufferSize, status)
; cnv : UConverter* -> "int"
; stackBuffer : void* in/out -> "intptr"
; pBufferSize : INT* in/out -> "var"
; status : UErrorCode* in/out -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procucnv_safeClone = icuuc.NewProc("ucnv_safeClone")
)

// cnv (UConverter*), stackBuffer (void* in/out), pBufferSize (INT* in/out), status (UErrorCode* in/out)
r1, _, err := procucnv_safeClone.Call(
	uintptr(cnv),
	uintptr(stackBuffer),
	uintptr(pBufferSize),
	uintptr(status),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // UConverter*
function ucnv_safeClone(
  cnv: Pointer;   // UConverter*
  stackBuffer: Pointer;   // void* in/out
  pBufferSize: Pointer;   // INT* in/out
  status: Pointer   // UErrorCode* in/out
): Pointer; cdecl;
  external 'icuuc.dll' name 'ucnv_safeClone';
result := DllCall("icuuc\ucnv_safeClone"
    , "Ptr", cnv   ; UConverter*
    , "Ptr", stackBuffer   ; void* in/out
    , "Ptr", pBufferSize   ; INT* in/out
    , "Ptr", status   ; UErrorCode* in/out
    , "Cdecl Ptr")   ; return: UConverter*
●ucnv_safeClone(cnv, stackBuffer, pBufferSize, status) = DLL("icuuc.dll", "void* ucnv_safeClone(void*, void*, void*, void*)")
# 呼び出し: ucnv_safeClone(cnv, stackBuffer, pBufferSize, status)
# cnv : UConverter* -> "void*"
# stackBuffer : void* in/out -> "void*"
# pBufferSize : INT* in/out -> "void*"
# status : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。