From ce8dd708c484c63a64b94273d3e962188cdcfede Mon Sep 17 00:00:00 2001 From: chenke <chenke@454eff88-639b-444f-9e54-f578c98de674> Date: 星期二, 25 七月 2017 17:47:57 +0800 Subject: [PATCH] 解决了java传递中文的显示问题 --- VisitFace/RtspNativeCodec/app/src/main/cpp/RtspNativeCodecJNI.cpp | 18 +++++++++++------- 1 files changed, 11 insertions(+), 7 deletions(-) diff --git a/VisitFace/RtspNativeCodec/app/src/main/cpp/RtspNativeCodecJNI.cpp b/VisitFace/RtspNativeCodec/app/src/main/cpp/RtspNativeCodecJNI.cpp index cbf9227..3d274d5 100644 --- a/VisitFace/RtspNativeCodec/app/src/main/cpp/RtspNativeCodecJNI.cpp +++ b/VisitFace/RtspNativeCodec/app/src/main/cpp/RtspNativeCodecJNI.cpp @@ -15,6 +15,7 @@ #include <face_daemon_proto.h> #include <stdlib.h> +#include <endian.h> #include "DebugNetwork.h" #include "TeleWrapper.h" @@ -792,13 +793,16 @@ assert(cameraIdx > 0 && cameraIdx <= CAMERA_COUNT); cameraIdx -= 1; CameraWrapper &cameraWrapper(g_CameraWrappers[cameraIdx]); + const jchar* jchars = env->GetStringChars(label, nullptr); + std::wstring wstr; + int lenth = env->GetStringLength(label); - const char *utfChars = env->GetStringUTFChars(label, NULL); - std::string labelstr(utfChars); - std::wstring wlabelstr; - wlabelstr.assign(labelstr.begin(), labelstr.end()); - env->ReleaseStringUTFChars(label, utfChars); - cameraWrapper.setFaceLabel(stTrackId, wlabelstr); + for (int i = 0; i < lenth; ++i) { + jchar jc = *(jchars + i); + wchar_t wt = (wchar_t)jc; + wstr.push_back(wt); + } + env->ReleaseStringChars(label,jchars); + cameraWrapper.setFaceLabel(stTrackId, wstr); } - } // extern C -- Gitblit v1.8.0