C 文字列操作 新しいページはコチラ

提供: yonewiki
移動: 案内, 検索
(文字列ファイルへの入出力)
(文字列ファイルへの入出力)
5,172行: 5,172行:
 
   int32_t int32FindCharSetCnt = 0;
 
   int32_t int32FindCharSetCnt = 0;
 
   int32_t int32Confidence = 0;
 
   int32_t int32Confidence = 0;
   const UCharsetMatch** pucsetmatchStrCode = ucsdet_detect(pucsetdetecDetector, &int32FindCharSetCnt &uerrorNum);
+
   const UCharsetMatch* pucsetmatchStrCode = ucsdet_detect(pucsetdetecDetector, &uerrorNum);
 +
  const UCharsetMatch** ppucsetmatchStrCode = ucsdet_detectAll(pucsetdetecDetector, &int32FindCharSetCnt, &uerrorNum);
 +
 
 
   const char* cpcDetectStrCodeName;
 
   const char* cpcDetectStrCodeName;
 
   const char* cpcDetectStrCodeLanguage;
 
   const char* cpcDetectStrCodeLanguage;
  
   cpcDetectStrCodeName = ucsdet_getName(pucsetmatchStrCode[配列番号], &uerrorNum);//文字コード名 ICUの文字コードセット名に適した形式。
+
   for(int i = 0; i < int32FindCharSetCnt; i++){
  cpcDetectStrCodeLanguage = ucsdet_getLanguage(pucsetmatchStrCode[配列番号], &uerrorNum);
+
    int32Confidence = ucsdet_getConfidence(ppucsetmatchStrCode[i], &uerrorNum);0~100で表される信頼値
  int32Confidence = ucsdet_getConfidence(pucsetmatchStrCode[配列番号], &uerrorNum);
+
    cpcDetectStrCodeName = ucsdet_getName(ppucsetmatchStrCode[i], &uerrorNum);//文字コード名 ICUの文字コードセット名に適した形式。
 +
    cpcDetectStrCodeLanguage = ucsdet_getLanguage(ppucsetmatchStrCode[i], &uerrorNum);  
 +
    printf("CodeConf->%d\n",int32Confidence);
 +
    printf("CodeName->%s\n",cpcDetectStrCodeName);
 +
    printf("CodeLang->%s\n",cpcDetectStrCodeLanguage);//RFC3066コードを取得できる。
 +
  }
 +
</syntaxhighlight>
 +
のようにするとConfidenceの値が大きいほど一致率が高いものとして確認ができます。全部を一覧するにはfor文で0~int32FindCharSetCnt -1までの要素を確認するとよいです。
 +
出力結果 UTF-16LEのファイル。
 +
<syntaxhighlight lang="text">
 +
CodeConf->100
 +
CodeName->UTF-16LE
 +
CodeLang->
 +
CodeConf->23
 +
CodeName->windows-1252
 +
CodeLang->es
 +
CodeConf->23
 +
CodeName->windows-1250
 +
CodeLang->cs
 +
CodeConf->10
 +
CodeName->UTF-16BE
 +
CodeLang->
 
</syntaxhighlight>
 
</syntaxhighlight>
のようにするとConfidenceの値が小さいほど一致率が高いものとして確認ができます。全部を一覧するにはfor文で0~int32FindCharSetCnt -1までの要素を確認するとよいです。
+
となります。
  
 
=='''文字列と数値の変換'''==
 
=='''文字列と数値の変換'''==

2014年10月16日 (木) 00:00時点における版



個人用ツール
名前空間

変種
操作
案内
ツールボックス