For the previous blog entry, I should add link to the original source. Please see here in OHAC project.

And sample completed code would be helpful.

#include<stdio.h>
#include<stdlib.h>
#include<locale.h>
#include<wchar.h>

int main(int argc, char *argv[]){

    wchar_t ws[BUFSIZ];

    setlocale(LC_ALL,"");

    if(argc<2){
        fprintf(stderr, "Need argument\n");
        exit(-1);
    }
    mbstowcs(ws, argv[1], BUFSIZ);
    printf("first:%wc\nlast :%wc\n", ws[0], ws[wcslen(ws)-1]);
}
Save it and compile. Below is example compiled as 'sample'.
% ./sample 国際化と地域化について
first char:国
last  char:て

Note that this is just sample and not care error handling and buffer size.

投稿されたコメント:

コメント
コメントは無効になっています。

This blog copyright 2008 by kazuhiko