0

我正在尝试 textinput 字符代码捕获,但特殊字符不起作用。请帮忙

import flash.text.TextField;
import flash.events.KeyboardEvent;

var dizi:Array = "şığ".split("");
tf.addEventListener(KeyboardEvent.KEY_DOWN, git);
function git(event:KeyboardEvent):void
{
    tf.restrict = dizi.toString();
    var harfsira:int= dizi.indexOf(String.fromCharCode(event.charCode));
    trace(dizi.toString());
    trace(harfsira.toString());
    trace(String.fromCharCode(event.charCode.toString()));

}

“ş”键被按下

ş,ı,ğ
-1
º

“ı”键被按下

ş,ı,ğ
-1
i

按下“ğ”键

ş,ı,ğ
-1
Û
4

2 回答 2

0

Does it help if you set the font to unicode Arial (it can handle special characters)?.

  var format_tf:TextFormat = new TextFormat();
  format_tf.font = "Arial"; //"Arial Unicode MS"
  format_tf.color = 0xFFFFFF; //white
  format_tf.size = 12; 

  tf.defaultTextFormat = format_tf;

  tf.addEventListener(KeyboardEvent.KEY_DOWN, git);

Or else my only experience of dealing with foreign & special characters is through byteArray. If the above doesn't work I will try to edit my answer to include converting via byteArray (note: not guaranteed to work or even time to do).

于 2013-11-07T03:42:43.880 回答
0

您从函数中获得的实际字符String.fromCharCode(event.charCode.toString())与数组中的字符不匹配。如果您确实按下了正确的键,则需要将数组更改为:

var dizi:Array = "ºiÛ".split("");

来修复这种不一致。

于 2013-11-05T17:30:25.450 回答