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複製先に使うユーザー確保バッファ。NULL可でヒープ確保となる。
pBufferSizeINT*inoutstackBufferのサイズを入出力するポインタ。0で必要量を問い合わせる。
statusUErrorCode*inoutエラーコードを入出力するポインタ。事前にU_ZERO_ERRORで初期化する。

戻り値の型: 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 varptr(cnv), stackBuffer, varptr(pBufferSize), varptr(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" var, sptr, var, var
; res = ucnv_safeClone(cnv, stackBuffer, pBufferSize, status)
; cnv : UConverter* -> "var"
; stackBuffer : void* in/out -> "sptr"
; pBufferSize : INT* in/out -> "var"
; status : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; UConverter* ucnv_safeClone(UConverter* cnv, void* stackBuffer, INT* pBufferSize, UErrorCode* status)
#uselib "icuuc.dll"
#cfunc global ucnv_safeClone "ucnv_safeClone" var, intptr, var, var
; res = ucnv_safeClone(cnv, stackBuffer, pBufferSize, status)
; cnv : UConverter* -> "var"
; stackBuffer : void* in/out -> "intptr"
; pBufferSize : INT* in/out -> "var"
; status : UErrorCode* in/out -> "var"
; ※出力/バッファ引数は 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`,…) を使用。
const std = @import("std");

extern "icuuc" fn ucnv_safeClone(
    cnv: [*c]isize, // UConverter*
    stackBuffer: ?*anyopaque, // void* in/out
    pBufferSize: [*c]i32, // INT* in/out
    status: [*c]i32 // UErrorCode* in/out
) callconv(.c) [*c]isize;
proc ucnv_safeClone(
    cnv: ptr int,  # UConverter*
    stackBuffer: pointer,  # void* in/out
    pBufferSize: ptr int32,  # INT* in/out
    status: ptr int32  # UErrorCode* in/out
): ptr int {.importc: "ucnv_safeClone", cdecl, dynlib: "icuuc.dll".}
pragma(lib, "icuuc");
extern(C)
ptrdiff_t* ucnv_safeClone(
    ptrdiff_t* cnv,   // UConverter*
    void* stackBuffer,   // void* in/out
    int* pBufferSize,   // INT* in/out
    int* status   // UErrorCode* in/out
);
ccall((:ucnv_safeClone, "icuuc.dll"), Ptr{Int},
      (Ptr{Int}, Ptr{Cvoid}, Ptr{Int32}, Ptr{Int32}),
      cnv, stackBuffer, pBufferSize, status)
# cnv : UConverter* -> Ptr{Int}
# stackBuffer : void* in/out -> Ptr{Cvoid}
# pBufferSize : INT* in/out -> Ptr{Int32}
# status : UErrorCode* in/out -> Ptr{Int32}
local ffi = require("ffi")
ffi.cdef[[
intptr_t* ucnv_safeClone(
    intptr_t* cnv,
    void* stackBuffer,
    int32_t* pBufferSize,
    int32_t* status);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.ucnv_safeClone(cnv, stackBuffer, pBufferSize, status)
-- cnv : UConverter*
-- stackBuffer : void* in/out
-- pBufferSize : INT* in/out
-- status : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const ucnv_safeClone = lib.func('__cdecl', 'ucnv_safeClone', 'intptr_t *', ['intptr_t *', 'void *', 'int32_t *', 'int32_t *']);
// ucnv_safeClone(cnv, stackBuffer, pBufferSize, status)
// cnv : UConverter* -> 'intptr_t *'
// stackBuffer : void* in/out -> 'void *'
// pBufferSize : INT* in/out -> 'int32_t *'
// status : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("icuuc.dll", {
  ucnv_safeClone: { parameters: ["pointer", "pointer", "pointer", "pointer"], result: "pointer" },
});
// lib.symbols.ucnv_safeClone(cnv, stackBuffer, pBufferSize, status)
// cnv : UConverter* -> "pointer"
// stackBuffer : void* in/out -> "pointer"
// pBufferSize : INT* in/out -> "pointer"
// status : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
intptr_t* ucnv_safeClone(
    intptr_t* cnv,
    void* stackBuffer,
    int32_t* pBufferSize,
    int32_t* status);
C, "icuuc.dll");
// $ffi->ucnv_safeClone(cnv, stackBuffer, pBufferSize, status);
// cnv : UConverter*
// stackBuffer : void* in/out
// pBufferSize : INT* in/out
// status : 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);
    Pointer ucnv_safeClone(
        LongByReference cnv,   // UConverter*
        Pointer stackBuffer,   // void* in/out
        IntByReference pBufferSize,   // INT* in/out
        IntByReference status   // UErrorCode* in/out
    );
}
@[Link("icuuc")]
lib Libicuuc
  fun ucnv_safeClone = ucnv_safeClone(
    cnv : LibC::SSizeT*,   # UConverter*
    stackBuffer : Void*,   # void* in/out
    pBufferSize : Int32*,   # INT* in/out
    status : Int32*   # UErrorCode* in/out
  ) : LibC::SSizeT*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ucnv_safeCloneNative = Pointer<IntPtr> Function(Pointer<IntPtr>, Pointer<Void>, Pointer<Int32>, Pointer<Int32>);
typedef ucnv_safeCloneDart = Pointer<IntPtr> Function(Pointer<IntPtr>, Pointer<Void>, Pointer<Int32>, Pointer<Int32>);
final ucnv_safeClone = DynamicLibrary.open('icuuc.dll')
    .lookupFunction<ucnv_safeCloneNative, ucnv_safeCloneDart>('ucnv_safeClone');
// cnv : UConverter* -> Pointer<IntPtr>
// stackBuffer : void* in/out -> Pointer<Void>
// pBufferSize : INT* in/out -> Pointer<Int32>
// status : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import ccall safe "ucnv_safeClone"
  c_ucnv_safeClone :: Ptr CIntPtr -> Ptr () -> Ptr Int32 -> Ptr Int32 -> IO (Ptr CIntPtr)
-- cnv : UConverter* -> Ptr CIntPtr
-- stackBuffer : void* in/out -> Ptr ()
-- pBufferSize : INT* in/out -> Ptr Int32
-- status : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ucnv_safeclone =
  foreign "ucnv_safeClone"
    ((ptr intptr_t) @-> (ptr void) @-> (ptr int32_t) @-> (ptr int32_t) @-> returning (ptr intptr_t))
(* cnv : UConverter* -> (ptr intptr_t) *)
(* stackBuffer : void* in/out -> (ptr void) *)
(* pBufferSize : INT* in/out -> (ptr int32_t) *)
(* status : 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_safeClone" ucnv-safe-clone :convention :cdecl) :pointer
  (cnv :pointer)   ; UConverter*
  (stack-buffer :pointer)   ; void* in/out
  (p-buffer-size :pointer)   ; INT* in/out
  (status :pointer))   ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ucnv_safeClone = Win32::API::More->new('icuuc',
    'LPVOID ucnv_safeClone(LPVOID cnv, LPVOID stackBuffer, LPVOID pBufferSize, LPVOID status)');
# my $ret = $ucnv_safeClone->Call($cnv, $stackBuffer, $pBufferSize, $status);
# cnv : UConverter* -> LPVOID
# stackBuffer : void* in/out -> LPVOID
# pBufferSize : INT* in/out -> LPVOID
# status : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型