MLTestUTF8String (C 関数)

MLTestUTF8StringWSTestUTF8Stringに置き換えられた.

int MLTestUTF8String(MLINK l, const unsigned char *s, int n)

l から読み込まれる次の式が値 s を持つ文字列であり,長さ n のUTF-8でコード化された文字列であることを検証する.

詳細

  • MLTestUTF8String()は,リンク上の現行のオブジェクトが文字列ではない場合,あるいは文字列の値が s にマッチしない場合には失敗する.
  • MLTestUTF8String()は,エラーが起った場合には0を,関数が成功した場合には非零の値を返す.
  • MLTestUTF8String()が失敗した場合には,MLError()を使ってエラーコードを得るとよい.
  • MLTestUTF8String()は,関数が失敗した場合には,MLTestUTF8String()を呼び出す直前のリンク上の式に対するストリームポインタを再設定する.この操作は,プログラマがMLCreateMark(link); MLTestUTF8String(); MLSeekToMark()を呼び出したかのように振舞う.
  • MLTestUTF8String()は,MathLinkヘッダファイルmathlink.hで宣言される.

例題

  (1)

#include "mathlink.h"

/* A function for testing the next expression on the link for a string */

void f(MLINK l)
{
    const unsigned char theString[8];

    theString[0] = '$'
    theString[1] = 'V';
    theString[2] = 'e';
    theString[3] = 'r';
    theString[4] = 's';
    theString[5] = 'i';
    theString[6] = 'o';
    theString[7] = 'n';

    if(! MLTestUTF8String(l, (const unsigned char *)theString,
        8))
    { /* The next expression on the link is not $Version */ }
    else
    { /* The next expression on the link is $Version */ }
}