简体   繁体   English

如何从Office365中的CHAR中获取ASCII

[英]How get ASCII from CHAR in Office365

I'm trying to learn how to build an Office365 Add-In to MS-Word. 我正在尝试学习如何将Office365加载项构建到MS-Word。

My problem is to get the ASCII-code of characters in text, since Office Javascript seems not have .charAt() function (although it has fromCharAt()). 我的问题是获取文本中字符的ASCII码,因为Office Javascript似乎没有.charAt()函数(尽管它具有fromCharAt())。

I had tried: - var.prototype.charAt() - var.charAt() << does not exist 我已经尝试过:-var.prototype.charAt()-var.charAt()<<不存在

My routine is: 我的例程是:

    var CurrentIndex = text.length,
        V_Temp,
        AsciiV_Temp;
    while (0 !== CurrentIndice) {
        CurrentIndex -= 1;
        V_Temp = text[CurrentIndex];
        AsciiV_Temp = ??????
    }

I would like to know how can I implement a function to do this or, in another way, if I can call a .NET Class to perform this function. 我想知道如何实现一个函数来执行此操作,或者是否可以调用.NET类来执行此功能。

I'm using Visual Studio 2013. 我正在使用Visual Studio 2013。

Thanks for any help. 谢谢你的帮助。

This is a work-round which will return the ascii value (it assumes you are using characters: space to ~ (32 to 126). 这是一个工作回合,它将返回ascii值(假定您正在使用字符:〜到空格(32到126)。

var ascVals="";
for (k=32; k < 127; k++) {
    ascVals+=String.fromCharCode(k);
}
alert(ascVals.indexOf("a")+32);

Will return 97. Replacing "a" with your CharacterForAsciiConversion will at least give you the value until you have a better solution. 将返回97。用CharacterForAsciiConversion替换“ a”至少会为您提供值,直到您有了更好的解决方案为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM