バイトを文字に変換しようとしているときに、ユニコーダー番号 0 (NUL) が検出されると、flex は変換を停止します。なぜそうなのですか?Flex は、0 を除く 1 ~ 256 の Unicode 番号を変換できます。次の例では、Unicode 番号から文字列メッセージを形成する際にパラメーターが 0 で始まっているため、Alert ウィンドウにはテキストが表示されません。
<?xml version="1.0" encoding="utf-8"?>
<s:Application name="Alert" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" creationComplete="init();">
<s:controlBarContent>
<s:Button id="btn"
label="Show alert"
click="init();"/>
</s:controlBarContent>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
protected function init():void {
// if string message value is String.fromCharCode(78,0);, then Alert displays as N
//Here, since message starts with unicode character 0, Alert displays nothing.
//Flex string is getting stopped if it encounters unicode 0, why is it so?
//but flex string supports other contorl ascii characters except NUL (0)
var message:String=String.fromCharCode(0, 78, 1);
Alert.show(message, "", Alert.YES | Alert.NO | Alert.OK | Alert.CANCEL);
}
]]>
</fx:Script>
</s:Application>
flex が Unicode 0 文字を変換できない理由がわかりません。一時的に、0 の場合は 32 (空白) に変換しています。よろしくお願いします。