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

ucasemap_utf8ToTitle

関数
UTF-8文字列をタイトルケースへ変換する。
DLLicuuc.dll呼出規約cdecl

シグネチャ

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

INT ucasemap_utf8ToTitle(
    UCaseMap* csm,
    LPSTR dest,
    INT destCapacity,
    LPCSTR src,
    INT srcLength,
    UErrorCode* pErrorCode
);

パラメーター

名前方向
csmUCaseMap*inout
destLPSTRin
destCapacityINTin
srcLPCSTRin
srcLengthINTin
pErrorCodeUErrorCode*inout

戻り値の型: INT

各言語での呼び出し定義

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

INT ucasemap_utf8ToTitle(
    UCaseMap* csm,
    LPSTR dest,
    INT destCapacity,
    LPCSTR src,
    INT srcLength,
    UErrorCode* pErrorCode
);
[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int ucasemap_utf8ToTitle(
    ref IntPtr csm,   // UCaseMap* in/out
    [MarshalAs(UnmanagedType.LPStr)] string dest,   // LPSTR
    int destCapacity,   // INT
    [MarshalAs(UnmanagedType.LPStr)] string src,   // LPCSTR
    int srcLength,   // INT
    ref int pErrorCode   // UErrorCode* in/out
);
<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function ucasemap_utf8ToTitle(
    ByRef csm As IntPtr,   ' UCaseMap* in/out
    <MarshalAs(UnmanagedType.LPStr)> dest As String,   ' LPSTR
    destCapacity As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPStr)> src As String,   ' LPCSTR
    srcLength As Integer,   ' INT
    ByRef pErrorCode As Integer   ' UErrorCode* in/out
) As Integer
End Function
' csm : UCaseMap* in/out
' dest : LPSTR
' destCapacity : INT
' src : LPCSTR
' srcLength : INT
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function ucasemap_utf8ToTitle Lib "icuuc" ( _
    ByRef csm As LongPtr, _
    ByVal dest As String, _
    ByVal destCapacity As Long, _
    ByVal src As String, _
    ByVal srcLength 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

ucasemap_utf8ToTitle = ctypes.cdll.icuuc.ucasemap_utf8ToTitle
ucasemap_utf8ToTitle.restype = ctypes.c_int
ucasemap_utf8ToTitle.argtypes = [
    ctypes.c_void_p,  # csm : UCaseMap* in/out
    wintypes.LPCSTR,  # dest : LPSTR
    ctypes.c_int,  # destCapacity : INT
    wintypes.LPCSTR,  # src : LPCSTR
    ctypes.c_int,  # srcLength : INT
    ctypes.c_void_p,  # pErrorCode : UErrorCode* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('icuuc.dll')
ucasemap_utf8ToTitle = Fiddle::Function.new(
  lib['ucasemap_utf8ToTitle'],
  [
    Fiddle::TYPE_VOIDP,  # csm : UCaseMap* in/out
    Fiddle::TYPE_VOIDP,  # dest : LPSTR
    Fiddle::TYPE_INT,  # destCapacity : INT
    Fiddle::TYPE_VOIDP,  # src : LPCSTR
    Fiddle::TYPE_INT,  # srcLength : INT
    Fiddle::TYPE_VOIDP,  # pErrorCode : UErrorCode* in/out
  ],
  Fiddle::TYPE_INT, Fiddle::Function::CDECL)
#[link(name = "icuuc")]
extern "C" {
    fn ucasemap_utf8ToTitle(
        csm: *mut isize,  // UCaseMap* in/out
        dest: *mut u8,  // LPSTR
        destCapacity: i32,  // INT
        src: *const u8,  // LPCSTR
        srcLength: 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 ucasemap_utf8ToTitle(ref IntPtr csm, [MarshalAs(UnmanagedType.LPStr)] string dest, int destCapacity, [MarshalAs(UnmanagedType.LPStr)] string src, int srcLength, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_ucasemap_utf8ToTitle' -Namespace Win32 -PassThru
# $api::ucasemap_utf8ToTitle(csm, dest, destCapacity, src, srcLength, pErrorCode)
#uselib "icuuc.dll"
#func global ucasemap_utf8ToTitle "ucasemap_utf8ToTitle" sptr, sptr, sptr, sptr, sptr, sptr
; ucasemap_utf8ToTitle csm, dest, destCapacity, src, srcLength, pErrorCode   ; 戻り値は stat
; csm : UCaseMap* in/out -> "sptr"
; dest : LPSTR -> "sptr"
; destCapacity : INT -> "sptr"
; src : LPCSTR -> "sptr"
; srcLength : INT -> "sptr"
; pErrorCode : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "icuuc.dll"
#cfunc global ucasemap_utf8ToTitle "ucasemap_utf8ToTitle" int, str, int, str, int, int
; res = ucasemap_utf8ToTitle(csm, dest, destCapacity, src, srcLength, pErrorCode)
; csm : UCaseMap* in/out -> "int"
; dest : LPSTR -> "str"
; destCapacity : INT -> "int"
; src : LPCSTR -> "str"
; srcLength : INT -> "int"
; pErrorCode : UErrorCode* in/out -> "int"
; INT ucasemap_utf8ToTitle(UCaseMap* csm, LPSTR dest, INT destCapacity, LPCSTR src, INT srcLength, UErrorCode* pErrorCode)
#uselib "icuuc.dll"
#cfunc global ucasemap_utf8ToTitle "ucasemap_utf8ToTitle" int, str, int, str, int, int
; res = ucasemap_utf8ToTitle(csm, dest, destCapacity, src, srcLength, pErrorCode)
; csm : UCaseMap* in/out -> "int"
; dest : LPSTR -> "str"
; destCapacity : INT -> "int"
; src : LPCSTR -> "str"
; srcLength : INT -> "int"
; pErrorCode : UErrorCode* in/out -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	icuuc = windows.NewLazySystemDLL("icuuc.dll")
	procucasemap_utf8ToTitle = icuuc.NewProc("ucasemap_utf8ToTitle")
)

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