標準/拡張機能 | C/C++ | 依存項目 |
---|---|---|
Language Environment | 両方 |
#include <collate.h>
int collrange(collel_t start, collel_t end, collel_t **list);
基本の重み が start および end ポイント (それぞれ を含む) の間にある照合エレメントのリストを検出します。戻される数字は、ポインターが戻されるリストのエレメントの数です。
end ポイントが start ポイントよりも 早くに照合すると、この値はゼロになります。戻されるリストは、setlocale() を次に呼び出すまで有効です。
正常に実行された場合、collrange() は、リストのエレメントの数を戻し、そのポインターが戻されます。
start または end のいずれかが範囲外の場合、collrange() は -1 を戻します。
⁄* CELEBC24
This example prints the collating elements in the range
between the start and end points passed in
argv[1] and argv[2], using the
&collrap. function.
*⁄
#include <stdio.h>
#include <locale.h>
#include <collate.h>
#include <stdlib.h>
#include <wctype.h>
#include <wchar.h>
main(int argc, char *argv[]) {
collel_t s, e, *rp;
int i;
setlocale(LC_ALL, "TEXAN.IBM-1024");
if ((s = strtocoll(argv[1])) == (collel_t)-1) {
printf("'%s' collating element not defined¥n", argv[1]);
exit(1);
}
if ((e = strtocoll(argv[2])) == (collel_t)-1) {
printf("'%s' collating element not defined¥n", argv[2]);
exit(1);
}
if ((i = collrange(s, e, &rp)) == -1) {
printf("Invalid range for '%s' to '%s'¥n", argv[1], argv[2]);
exit(1);
}
for (; i-- > 0; rp++) {
if (ismccollel(*rp))
printf("'%s' ", colltostr(*rp));
else if (iswprint(*rp))
printf("'%lc' ", *rp);
else
printf("'%x' ", *rp);
}
}