MLTestUTF16String (C 関数)
MLTestUTF16StringはWSTestUTF16Stringに置き換えられた.
int MLTestUTF16String(MLINK l, const unsigned short *s, int n)
l から読み込まれる次の式が値 s を持つ文字列であり,UTF-16でコード化された長さ n の文字列であることを検証する.
詳細

- MLTestUTF16String()は,リンク上の現行のオブジェクトが文字列ではない場合,あるいは文字列の値が s にマッチしない場合には失敗する.
- MLTestUTF16String()は,エラーが起った場合には0を,関数が成功した場合には非零の値を返す.
- MLTestUTF16String()が失敗した場合には,MLError()を使ってエラーコードを得るとよい.
- MLTestUTF16String()は,関数が失敗した場合には,MLTestUTF16String()を呼び出す直前のリンク上の式に対するストリームポインタを再設定する.この操作は,プログラマがMLCreateMark(link); MLTestUTF16String(…); MLSeekToMark(…)を呼び出したかのように振舞う.
- UTF-16でコード化された文字列 s には,バイトオーダーマークを含まなければならない.
- UTF-16の文字列 s の長さ n には,バイトオーダーマークを含まなければならない.
- MLTestUTF16String()は,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 short theString[9];
theString[0] = 0xFEFF;
theString[1] = '$'
theString[2] = 'V';
theString[3] = 'e';
theString[4] = 'r';
theString[5] = 's';
theString[6] = 'i';
theString[7] = 'o';
theString[8] = 'n';
if(! MLTestUTF16String(l, (const unsigned short *)theString,
9))
{ /* The next expression on the link is not $Version */ }
else
{ /* The next expression on the link is $Version */ }
}