0

chrome newer version(14) 不提供作为 NPVariant 的一部分的空终止字符串,而 firefox 的行为不同并提供空终止字符串。这是预期的吗??

除了提取字符串,分配内存并添加空字符然后释放相同的内容之外,我们还能做什么......所有这些只是为了添加一个空字符?

4

1 回答 1

2

NPVariant NPStrings have never been required to include a NULL terminated string. Sometimes they did anyway. What they do include, however, is a "length" to indicate how long the string is; I generally just convert it to a std::string like so:

retVal = std::string(npVar->value.stringValue.UTF8Characters, npVar->value.stringValue.UTF8Length);

That is how FireBreath does it; https://github.com/firebreath/FireBreath/blob/master/src/NpapiCore/NpapiBrowserHost.cpp#L253

于 2011-10-18T15:51:18.213 回答