Signed-off-by: shikai-123 <lifansheng1@huawei.com>

Modify defects
This commit is contained in:
shikai-123
2022-02-16 17:44:58 +08:00
parent d6c631d8bd
commit eaec996103
4 changed files with 9 additions and 9 deletions
+3 -3
View File
@@ -73,7 +73,7 @@ namespace OHOS::Util {
NAPI_CALL(env_, napi_get_typedarray_info(env_, src, &type, &length, &data1, &arrayBuffer, &byteOffset));
const char *source = static_cast<char*>(data1);
UErrorCode codeFlag = U_ZERO_ERROR;
size_t limit = GetMinByteSize() * length;
int32_t limit = GetMinByteSize() * length;
size_t len = limit * sizeof(UChar);
UChar *arr = nullptr;
if (limit > 0) {
@@ -146,12 +146,12 @@ namespace OHOS::Util {
return result;
}
size_t TextDecoder::GetMinByteSize() const
int32_t TextDecoder::GetMinByteSize() const
{
if (tranTool_ == nullptr) {
return -1;
}
size_t res = ucnv_getMinCharSize(tranTool_.get());
int32_t res = ucnv_getMinCharSize(tranTool_.get());
return res;
}
+3 -3
View File
@@ -26,7 +26,7 @@
using TransformToolPointer = std::unique_ptr<UConverter, void(*)(UConverter*)>;
namespace OHOS::Util {
struct DecodeArr {
DecodeArr(UChar *tarPos, size_t tarStaPos, size_t limLen)
DecodeArr(UChar *tarPos, size_t tarStaPos, int32_t limLen)
{
this->target = tarPos;
this->tarStartPos = tarStaPos;
@@ -34,7 +34,7 @@ namespace OHOS::Util {
}
UChar *target = 0;
size_t tarStartPos = 0;
size_t limitLen = 0;
int32_t limitLen = 0;
};
class TextDecoder {
@@ -53,7 +53,7 @@ namespace OHOS::Util {
napi_value GetEncoding() const;
napi_value GetFatal() const;
napi_value GetIgnoreBOM() const;
size_t GetMinByteSize() const;
int32_t GetMinByteSize() const;
void Reset() const;
UConverter *GetConverterPtr() const
{
+1 -1
View File
@@ -72,7 +72,7 @@ namespace OHOS::Util {
char *writeResult = static_cast<char*>(resultData) + byteOffset;
int32_t nchars = 0;
int32_t written = 0;
uint32_t written = 0;
NativeEngine *engine = reinterpret_cast<NativeEngine*>(env_);
NativeValue *nativeValue = reinterpret_cast<NativeValue*>(src);
engine->EncodeToUtf8(nativeValue, writeResult, &written, length, &nchars);
+2 -2
View File
@@ -191,8 +191,8 @@ namespace OHOS::Util {
size_t argc = 1;
napi_value argv = nullptr;
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, &argv, &thisVar, nullptr));
uint32_t err = 0;
NAPI_CALL(env, napi_get_value_uint32(env, argv, &err));
int32_t err = 0;
NAPI_CALL(env, napi_get_value_int32(env, argv, &err));
errInfo = strerror(err);
NAPI_CALL(env, napi_create_string_utf8(env, errInfo.c_str(), errInfo.size(), &result));
return result;