ホーム › Globalization › u_strToTitle
u_strToTitle
関数ロケールに従い文字列をタイトルケースに変換する。
シグネチャ
// icuuc.dll
#include <windows.h>
INT u_strToTitle(
WORD* dest,
INT destCapacity,
const WORD* src,
INT srcLength,
UBreakIterator* titleIter,
LPCSTR locale,
UErrorCode* pErrorCode
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dest | WORD* | inout |
| destCapacity | INT | in |
| src | WORD* | in |
| srcLength | INT | in |
| titleIter | UBreakIterator* | inout |
| locale | LPCSTR | in |
| pErrorCode | UErrorCode* | inout |
戻り値の型: INT
各言語での呼び出し定義
// icuuc.dll
#include <windows.h>
INT u_strToTitle(
WORD* dest,
INT destCapacity,
const WORD* src,
INT srcLength,
UBreakIterator* titleIter,
LPCSTR locale,
UErrorCode* pErrorCode
);[DllImport("icuuc.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int u_strToTitle(
ref ushort dest, // WORD* in/out
int destCapacity, // INT
ref ushort src, // WORD*
int srcLength, // INT
ref IntPtr titleIter, // UBreakIterator* in/out
[MarshalAs(UnmanagedType.LPStr)] string locale, // LPCSTR
ref int pErrorCode // UErrorCode* in/out
);<DllImport("icuuc.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function u_strToTitle(
ByRef dest As UShort, ' WORD* in/out
destCapacity As Integer, ' INT
ByRef src As UShort, ' WORD*
srcLength As Integer, ' INT
ByRef titleIter As IntPtr, ' UBreakIterator* in/out
<MarshalAs(UnmanagedType.LPStr)> locale As String, ' LPCSTR
ByRef pErrorCode As Integer ' UErrorCode* in/out
) As Integer
End Function' dest : WORD* in/out
' destCapacity : INT
' src : WORD*
' srcLength : INT
' titleIter : UBreakIterator* in/out
' locale : LPCSTR
' pErrorCode : UErrorCode* in/out
Declare PtrSafe Function u_strToTitle Lib "icuuc" ( _
ByRef dest As Integer, _
ByVal destCapacity As Long, _
ByRef src As Integer, _
ByVal srcLength As Long, _
ByRef titleIter As LongPtr, _
ByVal locale As String, _
ByRef pErrorCode As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
u_strToTitle = ctypes.cdll.icuuc.u_strToTitle
u_strToTitle.restype = ctypes.c_int
u_strToTitle.argtypes = [
ctypes.POINTER(ctypes.c_ushort), # dest : WORD* in/out
ctypes.c_int, # destCapacity : INT
ctypes.POINTER(ctypes.c_ushort), # src : WORD*
ctypes.c_int, # srcLength : INT
ctypes.c_void_p, # titleIter : UBreakIterator* in/out
wintypes.LPCSTR, # locale : LPCSTR
ctypes.c_void_p, # pErrorCode : UErrorCode* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('icuuc.dll')
u_strToTitle = Fiddle::Function.new(
lib['u_strToTitle'],
[
Fiddle::TYPE_VOIDP, # dest : WORD* in/out
Fiddle::TYPE_INT, # destCapacity : INT
Fiddle::TYPE_VOIDP, # src : WORD*
Fiddle::TYPE_INT, # srcLength : INT
Fiddle::TYPE_VOIDP, # titleIter : UBreakIterator* in/out
Fiddle::TYPE_VOIDP, # locale : LPCSTR
Fiddle::TYPE_VOIDP, # pErrorCode : UErrorCode* in/out
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "icuuc")]
extern "C" {
fn u_strToTitle(
dest: *mut u16, // WORD* in/out
destCapacity: i32, // INT
src: *const u16, // WORD*
srcLength: i32, // INT
titleIter: *mut isize, // UBreakIterator* in/out
locale: *const u8, // LPCSTR
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 u_strToTitle(ref ushort dest, int destCapacity, ref ushort src, int srcLength, ref IntPtr titleIter, [MarshalAs(UnmanagedType.LPStr)] string locale, ref int pErrorCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'icuuc_u_strToTitle' -Namespace Win32 -PassThru
# $api::u_strToTitle(dest, destCapacity, src, srcLength, titleIter, locale, pErrorCode)#uselib "icuuc.dll"
#func global u_strToTitle "u_strToTitle" sptr, sptr, sptr, sptr, sptr, sptr, sptr
; u_strToTitle varptr(dest), destCapacity, varptr(src), srcLength, titleIter, locale, pErrorCode ; 戻り値は stat
; dest : WORD* in/out -> "sptr"
; destCapacity : INT -> "sptr"
; src : WORD* -> "sptr"
; srcLength : INT -> "sptr"
; titleIter : UBreakIterator* in/out -> "sptr"
; locale : LPCSTR -> "sptr"
; pErrorCode : UErrorCode* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "icuuc.dll" #cfunc global u_strToTitle "u_strToTitle" var, int, var, int, int, str, int ; res = u_strToTitle(dest, destCapacity, src, srcLength, titleIter, locale, pErrorCode) ; dest : WORD* in/out -> "var" ; destCapacity : INT -> "int" ; src : WORD* -> "var" ; srcLength : INT -> "int" ; titleIter : UBreakIterator* in/out -> "int" ; locale : LPCSTR -> "str" ; pErrorCode : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global u_strToTitle "u_strToTitle" sptr, int, sptr, int, int, str, int ; res = u_strToTitle(varptr(dest), destCapacity, varptr(src), srcLength, titleIter, locale, pErrorCode) ; dest : WORD* in/out -> "sptr" ; destCapacity : INT -> "int" ; src : WORD* -> "sptr" ; srcLength : INT -> "int" ; titleIter : UBreakIterator* in/out -> "int" ; locale : LPCSTR -> "str" ; pErrorCode : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT u_strToTitle(WORD* dest, INT destCapacity, WORD* src, INT srcLength, UBreakIterator* titleIter, LPCSTR locale, UErrorCode* pErrorCode) #uselib "icuuc.dll" #cfunc global u_strToTitle "u_strToTitle" var, int, var, int, int, str, int ; res = u_strToTitle(dest, destCapacity, src, srcLength, titleIter, locale, pErrorCode) ; dest : WORD* in/out -> "var" ; destCapacity : INT -> "int" ; src : WORD* -> "var" ; srcLength : INT -> "int" ; titleIter : UBreakIterator* in/out -> "int" ; locale : LPCSTR -> "str" ; pErrorCode : UErrorCode* in/out -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT u_strToTitle(WORD* dest, INT destCapacity, WORD* src, INT srcLength, UBreakIterator* titleIter, LPCSTR locale, UErrorCode* pErrorCode) #uselib "icuuc.dll" #cfunc global u_strToTitle "u_strToTitle" intptr, int, intptr, int, int, str, int ; res = u_strToTitle(varptr(dest), destCapacity, varptr(src), srcLength, titleIter, locale, pErrorCode) ; dest : WORD* in/out -> "intptr" ; destCapacity : INT -> "int" ; src : WORD* -> "intptr" ; srcLength : INT -> "int" ; titleIter : UBreakIterator* in/out -> "int" ; locale : LPCSTR -> "str" ; pErrorCode : UErrorCode* in/out -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
icuuc = windows.NewLazySystemDLL("icuuc.dll")
procu_strToTitle = icuuc.NewProc("u_strToTitle")
)
// dest (WORD* in/out), destCapacity (INT), src (WORD*), srcLength (INT), titleIter (UBreakIterator* in/out), locale (LPCSTR), pErrorCode (UErrorCode* in/out)
r1, _, err := procu_strToTitle.Call(
uintptr(dest),
uintptr(destCapacity),
uintptr(src),
uintptr(srcLength),
uintptr(titleIter),
uintptr(unsafe.Pointer(windows.BytePtrFromString(locale))),
uintptr(pErrorCode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction u_strToTitle(
dest: Pointer; // WORD* in/out
destCapacity: Integer; // INT
src: Pointer; // WORD*
srcLength: Integer; // INT
titleIter: Pointer; // UBreakIterator* in/out
locale: PAnsiChar; // LPCSTR
pErrorCode: Pointer // UErrorCode* in/out
): Integer; cdecl;
external 'icuuc.dll' name 'u_strToTitle';result := DllCall("icuuc\u_strToTitle"
, "Ptr", dest ; WORD* in/out
, "Int", destCapacity ; INT
, "Ptr", src ; WORD*
, "Int", srcLength ; INT
, "Ptr", titleIter ; UBreakIterator* in/out
, "AStr", locale ; LPCSTR
, "Ptr", pErrorCode ; UErrorCode* in/out
, "Cdecl Int") ; return: INT●u_strToTitle(dest, destCapacity, src, srcLength, titleIter, locale, pErrorCode) = DLL("icuuc.dll", "int u_strToTitle(void*, int, void*, int, void*, char*, void*)")
# 呼び出し: u_strToTitle(dest, destCapacity, src, srcLength, titleIter, locale, pErrorCode)
# dest : WORD* in/out -> "void*"
# destCapacity : INT -> "int"
# src : WORD* -> "void*"
# srcLength : INT -> "int"
# titleIter : UBreakIterator* in/out -> "void*"
# locale : LPCSTR -> "char*"
# pErrorCode : UErrorCode* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。