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

ucnv_fromAlgorithmic

関数
指定アルゴリズム型のコードから変換する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

INT ucnv_fromAlgorithmic(
    UConverter* cnv,
    UConverterType algorithmicType,
    LPSTR target,
    INT targetCapacity,
    LPCSTR source,
    INT sourceLength,
    UErrorCode* pErrorCode
);

パラメーター

名前方向
cnvUConverter*inout
algorithmicTypeUConverterTypein
targetLPSTRin
targetCapacityINTin
sourceLPCSTRin
sourceLengthINTin
pErrorCodeUErrorCode*inout

戻り値の型: INT

各言語での呼び出し定義

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

INT ucnv_fromAlgorithmic(
    UConverter* cnv,
    UConverterType algorithmicType,
    LPSTR target,
    INT targetCapacity,
    LPCSTR source,
    INT sourceLength,
    UErrorCode* pErrorCode
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int ucnv_fromAlgorithmic(
    ref IntPtr cnv,   // UConverter* in/out
    int algorithmicType,   // UConverterType
    [MarshalAs(UnmanagedType.LPStr)] string target,   // LPSTR
    int targetCapacity,   // INT
    [MarshalAs(UnmanagedType.LPStr)] string source,   // LPCSTR
    int sourceLength,   // INT
    ref int pErrorCode   // UErrorCode* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucnv_fromAlgorithmic(
    ByRef cnv As IntPtr,   ' UConverter* in/out
    algorithmicType As Integer,   ' UConverterType
    <MarshalAs(UnmanagedType.LPStr)> target As String,   ' LPSTR
    targetCapacity As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPStr)> source As String,   ' LPCSTR
    sourceLength As Integer,   ' INT
    ByRef pErrorCode As Integer   ' UErrorCode* in/out
) As Integer
End Function
' cnv : UConverter* in/out
' algorithmicType : UConverterType
' target : LPSTR
' targetCapacity : INT
' source : LPCSTR
' sourceLength : INT
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function ucnv_fromAlgorithmic Lib "icuuc" ( _
    ByRef cnv As LongPtr, _
    ByVal algorithmicType As Long, _
    ByVal target As String, _
    ByVal targetCapacity As Long, _
    ByVal source As String, _
    ByVal sourceLength As Long, _
    ByRef pErrorCode As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ucnv_fromAlgorithmic = ctypes.cdll.icuuc.ucnv_fromAlgorithmic
ucnv_fromAlgorithmic.restype = ctypes.c_int
ucnv_fromAlgorithmic.argtypes = [
    ctypes.c_void_p,  # cnv : UConverter* in/out
    ctypes.c_int,  # algorithmicType : UConverterType
    wintypes.LPCSTR,  # target : LPSTR
    ctypes.c_int,  # targetCapacity : INT
    wintypes.LPCSTR,  # source : LPCSTR
    ctypes.c_int,  # sourceLength : INT
    ctypes.c_void_p,  # pErrorCode : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
ucnv_fromAlgorithmic = Fiddle::Function.new(
  lib['ucnv_fromAlgorithmic'],
  [
    Fiddle::TYPE_VOIDP,  # cnv : UConverter* in/out
    Fiddle::TYPE_INT,  # algorithmicType : UConverterType
    Fiddle::TYPE_VOIDP,  # target : LPSTR
    Fiddle::TYPE_INT,  # targetCapacity : INT
    Fiddle::TYPE_VOIDP,  # source : LPCSTR
    Fiddle::TYPE_INT,  # sourceLength : INT
    Fiddle::TYPE_VOIDP,  # pErrorCode : UErrorCode* in/out
  ],
  Fiddle::TYPE_INT, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn ucnv_fromAlgorithmic(
        cnv: *mut isize,  // UConverter* in/out
        algorithmicType: i32,  // UConverterType
        target: *mut u8,  // LPSTR
        targetCapacity: i32,  // INT
        source: *const u8,  // LPCSTR
        sourceLength: i32,  // INT
        pErrorCode: *mut i32  // UErrorCode* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("icuuc.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int ucnv_fromAlgorithmic(ref IntPtr cnv, int algorithmicType, [MarshalAs(UnmanagedType.LPStr)] string target, int targetCapacity, [MarshalAs(UnmanagedType.LPStr)] string source, int sourceLength, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ucnv_fromAlgorithmic' -Namespace Win32 -PassThru
# $api::ucnv_fromAlgorithmic(cnv, algorithmicType, target, targetCapacity, source, sourceLength, pErrorCode)
#uselib "icuuc.dll"
#func global ucnv_fromAlgorithmic "ucnv_fromAlgorithmic" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; ucnv_fromAlgorithmic cnv, algorithmicType, target, targetCapacity, source, sourceLength, pErrorCode   ; 戻り値は stat
; cnv : UConverter* in/out -> "sptr"
; algorithmicType : UConverterType -> "sptr"
; target : LPSTR -> "sptr"
; targetCapacity : INT -> "sptr"
; source : LPCSTR -> "sptr"
; sourceLength : INT -> "sptr"
; pErrorCode : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "icuuc.dll"
#cfunc global ucnv_fromAlgorithmic "ucnv_fromAlgorithmic" int, int, str, int, str, int, int
; res = ucnv_fromAlgorithmic(cnv, algorithmicType, target, targetCapacity, source, sourceLength, pErrorCode)
; cnv : UConverter* in/out -> "int"
; algorithmicType : UConverterType -> "int"
; target : LPSTR -> "str"
; targetCapacity : INT -> "int"
; source : LPCSTR -> "str"
; sourceLength : INT -> "int"
; pErrorCode : UErrorCode* in/out -> "int"
; INT ucnv_fromAlgorithmic(UConverter* cnv, UConverterType algorithmicType, LPSTR target, INT targetCapacity, LPCSTR source, INT sourceLength, UErrorCode* pErrorCode)
#uselib "icuuc.dll"
#cfunc global ucnv_fromAlgorithmic "ucnv_fromAlgorithmic" int, int, str, int, str, int, int
; res = ucnv_fromAlgorithmic(cnv, algorithmicType, target, targetCapacity, source, sourceLength, pErrorCode)
; cnv : UConverter* in/out -> "int"
; algorithmicType : UConverterType -> "int"
; target : LPSTR -> "str"
; targetCapacity : INT -> "int"
; source : LPCSTR -> "str"
; sourceLength : INT -> "int"
; pErrorCode : UErrorCode* in/out -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procucnv_fromAlgorithmic = icuuc.NewProc("ucnv_fromAlgorithmic")
)

// cnv (UConverter* in/out), algorithmicType (UConverterType), target (LPSTR), targetCapacity (INT), source (LPCSTR), sourceLength (INT), pErrorCode (UErrorCode* in/out)
r1, _, err := procucnv_fromAlgorithmic.Call(
	uintptr(cnv),
	uintptr(algorithmicType),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(target))),
	uintptr(targetCapacity),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(source))),
	uintptr(sourceLength),
	uintptr(pErrorCode),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function ucnv_fromAlgorithmic(
  cnv: Pointer;   // UConverter* in/out
  algorithmicType: Integer;   // UConverterType
  target: PAnsiChar;   // LPSTR
  targetCapacity: Integer;   // INT
  source: PAnsiChar;   // LPCSTR
  sourceLength: Integer;   // INT
  pErrorCode: Pointer   // UErrorCode* in/out
): Integer; cdecl;
  external 'icuuc.dll' name 'ucnv_fromAlgorithmic';
result := DllCall("icuuc\ucnv_fromAlgorithmic"
    , "Ptr", cnv   ; UConverter* in/out
    , "Int", algorithmicType   ; UConverterType
    , "AStr", target   ; LPSTR
    , "Int", targetCapacity   ; INT
    , "AStr", source   ; LPCSTR
    , "Int", sourceLength   ; INT
    , "Ptr", pErrorCode   ; UErrorCode* in/out
    , "Cdecl Int")   ; return: INT
●ucnv_fromAlgorithmic(cnv, algorithmicType, target, targetCapacity, source, sourceLength, pErrorCode) = DLL("icuuc.dll", "int ucnv_fromAlgorithmic(void*, int, char*, int, char*, int, void*)")
# 呼び出し: ucnv_fromAlgorithmic(cnv, algorithmicType, target, targetCapacity, source, sourceLength, pErrorCode)
# cnv : UConverter* in/out -> "void*"
# algorithmicType : UConverterType -> "int"
# target : LPSTR -> "char*"
# targetCapacity : INT -> "int"
# source : LPCSTR -> "char*"
# sourceLength : INT -> "int"
# pErrorCode : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。