mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2025-02-21 12:51:58 +00:00
修复strlen无法编译问题
Signed-off-by: liumingxiang1 <liumingxiang1@huawei.com>
This commit is contained in:
parent
fe90427424
commit
5afe7daa58
@ -169,7 +169,7 @@ napi_value JsParagraphBuilder::OnAddText(napi_env env, napi_callback_info info)
|
||||
}
|
||||
std::string text = "";
|
||||
if (ConvertFromJsValue(env, argv[0], text)) {
|
||||
if (!IsUtf8(text.c_str())) {
|
||||
if (!IsUtf8(text.c_str(), text.size())) {
|
||||
TEXT_LOGE("Invalid utf-8 text");
|
||||
return NapiThrowError(env, TextErrorCode::ERROR_INVALID_PARAM, "Invalid params.");
|
||||
}
|
||||
|
@ -432,7 +432,7 @@ void OH_Drawing_TypographyHandlerAddText(OH_Drawing_TypographyCreate* handler, c
|
||||
if (!text || !handler) {
|
||||
LOGE("null text");
|
||||
return;
|
||||
} else if (!IsUtf8(text)) {
|
||||
} else if (!IsUtf8(text, strlen(text))) {
|
||||
LOGE("text is not utf-8");
|
||||
return;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
|
||||
bool IsUtf8(const char* text);
|
||||
bool IsUtf8(const char* text, int len);
|
||||
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
@ -12,15 +12,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
#include "utils/string_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
bool IsUtf8(const char* text)
|
||||
bool IsUtf8(const char* text, int len)
|
||||
{
|
||||
int len = strlen(text);
|
||||
int n;
|
||||
int i = 0;
|
||||
while (i < len) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user