| 前へ | 次へ | 目次 | 索引 |
<戻り値>
| match | 1 : 文字列1が文字列2で始まっている |
| 0 : 文字列1が文字列2で始まっていない |
英大文字/小文字,全角/半角,ひらがな/カタカナ変換による文字列の検索
検索文字列が含まれていない場合は0を返します。
<形式>
index = JLB$STR_SEARCH ( src-str, sub-str [[, start-pos][, flg]] )
<引数>
| src-str | ||
|---|---|---|
| JLB usage | 入力文字列 | |
| access | 入力のみ | |
| mechanism | Descriptor渡し | |
| sub-str | ||
| JLB usage | 検索文字列 | |
| access | 入力のみ | |
| mechanism | Descriptor渡し | |
| start-pos | ||
| JLB usage | 検索開始文字位置 (省略時は1) | |
| type | Longword | |
| access | 入力のみ | |
| mechanism | Reference渡し | |
| flg | ||
| JLB usage | 変換フラグ (省略時は0) | |
| type | Byte | |
| access | 入力のみ | |
| mechanism | Reference渡し | |
| 検索の前に行う変換を指定する。 | ||
| bit 0 | 0 : 英大文字/小文字変換を行う | |
| 1 : 英大文字/小文字変換を行わない | ||
| bit 1 | 0 : 全角/半角変換を行う | |
| 1 : 全角/半角変換を行わない | ||
| bit 2 | 0 : ひらがな/カタカナ変換を行う | |
| 1 : ひらがな/カタカナ変換を行わない | ||
<戻り値>
| index | 検索文字列が含まれている場合はその開始位置 |
| 検索文字列が含まれていなければ 0 | |
| 検索文字列の長さがゼロの場合は 1 |
例)
#include <stdio.h>
#include <descrip.h>
#include <string.h>
main()
{
struct dsc$descriptor_s src_str;
struct dsc$descriptor_s sub_str;
char flg;
int index;
extern int jlb$str_search();
char src_str_body[] = "日本語ライブラリ",
sub_str_body[] = "らいぶらり";
int start_pos = 1;
src_str.dsc$b_class = DSC$K_CLASS_S;
src_str.dsc$b_dtype = DSC$K_DTYPE_T;
src_str.dsc$w_length = strlen( src_str_body );
src_str.dsc$a_pointer = src_str_body;
sub_str.dsc$b_class = DSC$K_CLASS_S;
sub_str.dsc$b_dtype = DSC$K_DTYPE_T;
sub_str.dsc$w_length = strlen( sub_str_body );
sub_str.dsc$a_pointer = sub_str_body;
printf( "文字列 1:\"%s\" 文字列 2:\"%s\"\n", src_str_body, sub_str_body);
for ( flg = 0; flg < 8; ++flg ) {
index = jlb$str_search( &src_str, &sub_str, &start_pos, &flg );
printf( "変換フラグ :%1d 結果 :%d\n", flg, index );
}
}
|
文字列の後の空白の切り捨て
文字列の後に含まれる空白(半角および全角)ならびにタブを切り捨てます。
<形式>
ret-status = JLB$TRIM ( dst-str, src-str [, out-len] )
<引数>
| dst-str | |
|---|---|
| JLB usage | 出力文字列 |
| access | 出力のみ |
| mechanism | Descriptor渡し |
| src-str | |
| JLB usage | 入力文字列 |
| access | 入力のみ |
| mechanism | Descriptor渡し |
| out-len | |
| JLB usage | 出力文字列のバイト長 (省略時は長さが返りません。) |
| type | Word |
| access | 出力のみ |
| mechanism | Reference渡し |
<戻り値>
| ret-status | SS$_NORMAL | 正常終了 |
| LIB$_STRTRU | 出力文字列用領域の長さが足りないため,出力結果の切り捨てが行われた |
例)
#include <stdio.h>
#include <descrip.h>
#include <ssdef.h>
#include <libdef.h>
#include <string.h>
#include <ssdef.h>
#include <stsdef.h>
#include <varargs.h>
main()
{
struct dsc$descriptor_s dst_str;
struct dsc$descriptor_s src_str;
int ret_status;
extern int jlb$trim();
char src_str_body[] = "日本語 ";
char dst_str_body[] = "外国人 ";
dst_str.dsc$b_class = src_str.dsc$b_class = DSC$K_CLASS_S;
dst_str.dsc$b_dtype = src_str.dsc$b_dtype = DSC$K_DTYPE_T;
src_str.dsc$w_length = strlen (src_str_body);
dst_str.dsc$w_length = strlen (dst_str_body);
src_str.dsc$a_pointer = src_str_body;
dst_str.dsc$a_pointer = dst_str_body;
printf( "入力文字列 :\"%s\"\n", src_str_body );
ret_status = jlb$trim( &dst_str, &src_str, &dst_str.dsc$w_length );
dst_str_body[ dst_str.dsc$w_length ] = '\0';
printf( "出力文字列 :\"%s\" 文字列長 :%d ステータス :",
dst_str.dsc$a_pointer, dst_str.dsc$w_length );
switch ( ret_status ) {
case SS$_NORMAL:
printf( "SS$_NORMAL" );
break;
case LIB$_STRTRU:
printf( "LIB$_STRTRU" );
break;
}
putchar( '\n' );
}
|
文字列の切り捨て
文字列を指定された長さで切り捨てます。
<形式>
ret-status = JLB$TRUNC ( dst-str, src-str, size [, out-len] )
<引数>
| dst-str | |
|---|---|
| JLB usage | 出力文字列 |
| access | 出力のみ |
| mechanism | Descriptor渡し |
| src-str | |
| JLB usage | 入力文字列 |
| access | 入力のみ |
| mechanism | Descriptor渡し |
| size | |
| JLB usage | 切り捨てを行う長さ |
| type | Word |
| access | 入力のみ |
| mechanism | Reference渡し |
| out-len | |
| JLB usage | 出力文字列のバイト長 |
| type | Word |
| access | 出力のみ |
| mechanism | Reference渡し |
<戻り値>
| ret-status | SS$_NORMAL | 正常終了 |
| LIB$_STRTRU | 出力結果の切り捨てが行われた |
文字の検索
入力文字列中で最初に現れた検索文字の文字位置を返します。検索文字が含まれていない場合は0を返します。
<形式>
index = JLB$LOCC ( char-str, src-str )
<引数>
| char-str | |
|---|---|
| JLB usage | 検索文字 |
| access | 入力のみ |
| mechanism | Descriptor渡し |
| src-str | |
| JLB usage | 入力文字列 |
| access | 入力のみ |
| mechanism | Descriptor渡し |
<戻り値>
| index | 文字位置 |
例)
#include <stdio.h>
#include <descrip.h>
#include <string.h>
main()
{
struct dsc$descriptor_s char_str;
struct dsc$descriptor_s src_str;
int index;
extern int jlb$locc();
char char_str_body[] = "本",
src_str_body[] = "日本語";
char_str.dsc$b_class = src_str.dsc$b_class = DSC$K_CLASS_S;
char_str.dsc$b_dtype = src_str.dsc$b_dtype = DSC$K_DTYPE_T;
char_str.dsc$w_length = strlen( char_str_body );
char_str.dsc$a_pointer = char_str_body;
src_str.dsc$w_length = strlen( src_str_body );
src_str.dsc$a_pointer = src_str_body;
index = jlb$locc( &char_str, &src_str );
printf( "検索文字 :\'%s\' 入力文字列 :\"%s\"\n 結果 :%d\n",
char_str_body, src_str_body, index );
}
|
文字の飛び越し
入力文字列中で最初に現れた検索文字以外の文字位置を返します。検索文字以外の文字がない場合は0を返します。
<形式>
index = JLB$SKPC ( char-str, src-str )
<引数>
| char-str | |
|---|---|
| JLB usage | 検索文字 |
| access | 入力のみ |
| mechanism | Descriptor渡し |
| src-str | |
| JLB usage | 入力文字列 |
| access | 入力のみ |
| mechanism | Descriptor渡し |
<戻り値>
| index | 文字位置 |
| char-str の長さがゼロの場合は 1 |
文字列からの文字の取り出し
<形式>
char-code = JLB$RCHAR ( src-str [, pos] )
<引数>
| src-str | |
|---|---|
| JLB usage | 入力文字列 |
| access | 入力のみ |
| mechanism | Descriptor渡し |
| pos | |
| JLB usage | 文字位置 |
| type | Longword |
| access | 入力のみ |
| mechanism | Reference渡し |
<戻り値>
| char-code | 文字コード |
文字列からの文字の取り出しおよびインデックスの更新
<形式>
char-code = JLB$RNEXT ( src-str [, pos] )
<引数>
| src-str | |
|---|---|
| JLB usage | 入力文字列 |
| access | 入力のみ |
| mechanism | Descriptor渡し |
| pos | |
| JLB usage | 文字位置 |
| type | Longword |
| access | 更新 |
| mechanism | Reference渡し |
<戻り値>
| char-code | 文字コード |
文字列への文字の書き込み
<形式>
ret-status = JLB$WCHAR ( char-code, dst-str [, pos] )
<引数>
| char-code | |
|---|---|
| JLB usage | 文字コード |
| type | Longword |
| access | 入力のみ |
| mechanism | Reference渡し |
| dst-str | |
| JLB usage | 出力文字列 |
| access | 出力のみ |
| mechanism | Descriptor渡し |
| pos | |
| JLB usage | 文字位置 |
| type | Longword |
| access | 入力のみ |
| mechanism | Reference渡し |
<戻り値>
| ret-status | 1 : 正常終了 |
| 0 : 出力文字列の長さが短い |
文字列への文字の書き込みおよびインデックスの更新
<形式>
ret-status = JLB$WNEXT ( char-code, dst-str [, pos] )
<引数>
| char-code | |
|---|---|
| JLB usagec: | 文字コード |
| type | Longword |
| access | 入力のみ |
| mechanism | Reference渡し |
| dst-str | |
| JLB usage | 出力文字列 |
| access | 出力のみ |
| mechanism | Descriptor渡し |
| pos | |
| JLB usage | 文字位置 |
| type | Longword |
| access | 更新 |
| mechanism | Reference渡し |
<戻り値>
| ret-status | 1 : 正常終了 |
| 0 : 出力文字列の長さが短い |
| 前へ | 次へ | 目次 | 索引 |