JNI中文处理问题小结[11]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

        strcpy (mChars, rhs.mChars);

        mString = rhs.mString.c_str ();
    }


    // Delete the instance and release allocated storage
    ~JNIString() { delete [] mChars; }

    // assign a new value to this instance from the given string
    JNIString & operator =(const string& rhs) {
        delete
 [] mChars;

        int
 slen = rhs.length ();
        jchar* buffer = new jchar[slen];
        int
 len = MultiByteToWideChar (CP_ACP, 0, rhs.c_str (), rhs.length (), buffer, slen);

        if
 (len > 0 && len < slen)
            buffer[len] = 0;

        mJstr = mEnv->NewString (buffer, len);
        delete
 [] buffer;

        mChars = new char[rhs.length () + 1];

本文关键:JNI中文处理问题小结
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top