ホーム › 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 | タイトルケース化結果を格納するUTF-16出力バッファ。容量取得時はNULL可。 |
| destCapacity | INT | in | destの容量をUChar単位で指定する。0で事前長取得。 |
| src | WORD* | in | タイトルケース化対象の入力UTF-16文字列を指す。 |
| srcLength | INT | in | srcの長さをUChar単位で指定する。-1でNUL終端。 |
| titleIter | UBreakIterator* | inout | 語頭境界を決める区切り反復子。NULLで既定の単語境界を使用。 |
| locale | LPCSTR | in | ケース変換規則に用いるロケールID。NULLで既定ロケール。 |
| pErrorCode | UErrorCode* | inout | ICUエラーコードを入出力するポインタ。呼出前に成功値で初期化する。 |
戻り値の型: 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, varptr(titleIter), locale, varptr(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, var, str, var ; 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 -> "var" ; locale : LPCSTR -> "str" ; pErrorCode : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "icuuc.dll" #cfunc global u_strToTitle "u_strToTitle" sptr, int, sptr, int, sptr, str, sptr ; res = u_strToTitle(varptr(dest), destCapacity, varptr(src), srcLength, varptr(titleIter), locale, varptr(pErrorCode)) ; dest : WORD* in/out -> "sptr" ; destCapacity : INT -> "int" ; src : WORD* -> "sptr" ; srcLength : INT -> "int" ; titleIter : UBreakIterator* in/out -> "sptr" ; locale : LPCSTR -> "str" ; pErrorCode : UErrorCode* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(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, var, str, var ; 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 -> "var" ; locale : LPCSTR -> "str" ; pErrorCode : UErrorCode* in/out -> "var" ; ※出力/バッファ引数は 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, intptr, str, intptr ; res = u_strToTitle(varptr(dest), destCapacity, varptr(src), srcLength, varptr(titleIter), locale, varptr(pErrorCode)) ; dest : WORD* in/out -> "intptr" ; destCapacity : INT -> "int" ; src : WORD* -> "intptr" ; srcLength : INT -> "int" ; titleIter : UBreakIterator* in/out -> "intptr" ; locale : LPCSTR -> "str" ; pErrorCode : UErrorCode* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(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`,…) を使用。const std = @import("std");
extern "icuuc" fn u_strToTitle(
dest: [*c]u16, // WORD* in/out
destCapacity: i32, // INT
src: [*c]u16, // WORD*
srcLength: i32, // INT
titleIter: [*c]isize, // UBreakIterator* in/out
locale: [*c]const u8, // LPCSTR
pErrorCode: [*c]i32 // UErrorCode* in/out
) callconv(.c) i32;proc u_strToTitle(
dest: ptr uint16, # WORD* in/out
destCapacity: int32, # INT
src: ptr uint16, # WORD*
srcLength: int32, # INT
titleIter: ptr int, # UBreakIterator* in/out
locale: cstring, # LPCSTR
pErrorCode: ptr int32 # UErrorCode* in/out
): int32 {.importc: "u_strToTitle", cdecl, dynlib: "icuuc.dll".}pragma(lib, "icuuc");
extern(C)
int u_strToTitle(
ushort* dest, // WORD* in/out
int destCapacity, // INT
ushort* src, // WORD*
int srcLength, // INT
ptrdiff_t* titleIter, // UBreakIterator* in/out
const(char)* locale, // LPCSTR
int* pErrorCode // UErrorCode* in/out
);ccall((:u_strToTitle, "icuuc.dll"), Int32,
(Ptr{UInt16}, Int32, Ptr{UInt16}, Int32, Ptr{Int}, Cstring, Ptr{Int32}),
dest, destCapacity, src, srcLength, titleIter, locale, pErrorCode)
# dest : WORD* in/out -> Ptr{UInt16}
# destCapacity : INT -> Int32
# src : WORD* -> Ptr{UInt16}
# srcLength : INT -> Int32
# titleIter : UBreakIterator* in/out -> Ptr{Int}
# locale : LPCSTR -> Cstring
# pErrorCode : UErrorCode* in/out -> Ptr{Int32}local ffi = require("ffi")
ffi.cdef[[
int32_t u_strToTitle(
uint16_t* dest,
int32_t destCapacity,
uint16_t* src,
int32_t srcLength,
intptr_t* titleIter,
const char* locale,
int32_t* pErrorCode);
]]
local icuuc = ffi.load("icuuc")
-- icuuc.u_strToTitle(dest, destCapacity, src, srcLength, titleIter, locale, pErrorCode)
-- dest : WORD* in/out
-- destCapacity : INT
-- src : WORD*
-- srcLength : INT
-- titleIter : UBreakIterator* in/out
-- locale : LPCSTR
-- pErrorCode : UErrorCode* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('icuuc.dll');
const u_strToTitle = lib.func('__cdecl', 'u_strToTitle', 'int32_t', ['uint16_t *', 'int32_t', 'uint16_t *', 'int32_t', 'intptr_t *', 'str', 'int32_t *']);
// u_strToTitle(dest, destCapacity, src, srcLength, titleIter, locale, pErrorCode)
// dest : WORD* in/out -> 'uint16_t *'
// destCapacity : INT -> 'int32_t'
// src : WORD* -> 'uint16_t *'
// srcLength : INT -> 'int32_t'
// titleIter : UBreakIterator* in/out -> 'intptr_t *'
// locale : LPCSTR -> 'str'
// pErrorCode : UErrorCode* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("icuuc.dll", {
u_strToTitle: { parameters: ["pointer", "i32", "pointer", "i32", "pointer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.u_strToTitle(dest, destCapacity, src, srcLength, titleIter, locale, pErrorCode)
// dest : WORD* in/out -> "pointer"
// destCapacity : INT -> "i32"
// src : WORD* -> "pointer"
// srcLength : INT -> "i32"
// titleIter : UBreakIterator* in/out -> "pointer"
// locale : LPCSTR -> "buffer"
// pErrorCode : UErrorCode* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t u_strToTitle(
uint16_t* dest,
int32_t destCapacity,
uint16_t* src,
int32_t srcLength,
intptr_t* titleIter,
const char* locale,
int32_t* pErrorCode);
C, "icuuc.dll");
// $ffi->u_strToTitle(dest, destCapacity, src, srcLength, titleIter, locale, pErrorCode);
// dest : WORD* in/out
// destCapacity : INT
// src : WORD*
// srcLength : INT
// titleIter : UBreakIterator* in/out
// locale : LPCSTR
// pErrorCode : 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);
int u_strToTitle(
ShortByReference dest, // WORD* in/out
int destCapacity, // INT
ShortByReference src, // WORD*
int srcLength, // INT
LongByReference titleIter, // UBreakIterator* in/out
String locale, // LPCSTR
IntByReference pErrorCode // UErrorCode* in/out
);
}@[Link("icuuc")]
lib Libicuuc
fun u_strToTitle = u_strToTitle(
dest : UInt16*, # WORD* in/out
destCapacity : Int32, # INT
src : UInt16*, # WORD*
srcLength : Int32, # INT
titleIter : LibC::SSizeT*, # UBreakIterator* in/out
locale : UInt8*, # LPCSTR
pErrorCode : Int32* # UErrorCode* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef u_strToTitleNative = Int32 Function(Pointer<Uint16>, Int32, Pointer<Uint16>, Int32, Pointer<IntPtr>, Pointer<Utf8>, Pointer<Int32>);
typedef u_strToTitleDart = int Function(Pointer<Uint16>, int, Pointer<Uint16>, int, Pointer<IntPtr>, Pointer<Utf8>, Pointer<Int32>);
final u_strToTitle = DynamicLibrary.open('icuuc.dll')
.lookupFunction<u_strToTitleNative, u_strToTitleDart>('u_strToTitle');
// dest : WORD* in/out -> Pointer<Uint16>
// destCapacity : INT -> Int32
// src : WORD* -> Pointer<Uint16>
// srcLength : INT -> Int32
// titleIter : UBreakIterator* in/out -> Pointer<IntPtr>
// locale : LPCSTR -> Pointer<Utf8>
// pErrorCode : UErrorCode* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function 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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "u_strToTitle"
c_u_strToTitle :: Ptr Word16 -> Int32 -> Ptr Word16 -> Int32 -> Ptr CIntPtr -> CString -> Ptr Int32 -> IO Int32
-- dest : WORD* in/out -> Ptr Word16
-- destCapacity : INT -> Int32
-- src : WORD* -> Ptr Word16
-- srcLength : INT -> Int32
-- titleIter : UBreakIterator* in/out -> Ptr CIntPtr
-- locale : LPCSTR -> CString
-- pErrorCode : UErrorCode* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let u_strtotitle =
foreign "u_strToTitle"
((ptr uint16_t) @-> int32_t @-> (ptr uint16_t) @-> int32_t @-> (ptr intptr_t) @-> string @-> (ptr int32_t) @-> returning int32_t)
(* dest : WORD* in/out -> (ptr uint16_t) *)
(* destCapacity : INT -> int32_t *)
(* src : WORD* -> (ptr uint16_t) *)
(* srcLength : INT -> int32_t *)
(* titleIter : UBreakIterator* in/out -> (ptr intptr_t) *)
(* locale : LPCSTR -> string *)
(* pErrorCode : 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 ("u_strToTitle" u-str-to-title :convention :cdecl) :int32
(dest :pointer) ; WORD* in/out
(dest-capacity :int32) ; INT
(src :pointer) ; WORD*
(src-length :int32) ; INT
(title-iter :pointer) ; UBreakIterator* in/out
(locale :string) ; LPCSTR
(p-error-code :pointer)) ; UErrorCode* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $u_strToTitle = Win32::API::More->new('icuuc',
'int u_strToTitle(LPVOID dest, int destCapacity, LPVOID src, int srcLength, LPVOID titleIter, LPCSTR locale, LPVOID pErrorCode)');
# my $ret = $u_strToTitle->Call($dest, $destCapacity, $src, $srcLength, $titleIter, $locale, $pErrorCode);
# dest : WORD* in/out -> LPVOID
# destCapacity : INT -> int
# src : WORD* -> LPVOID
# srcLength : INT -> int
# titleIter : UBreakIterator* in/out -> LPVOID
# locale : LPCSTR -> LPCSTR
# pErrorCode : UErrorCode* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型