Merge "USB string descriptors are not UTF8, so it is not safe to treat them as such." into lmp-dev

This commit is contained in:
Mike Lockwood
2014-09-19 02:00:25 +00:00
committed by Android (Google) Code Review
3 changed files with 22 additions and 5 deletions

View File

@@ -905,6 +905,20 @@ char* AndroidRuntime::toSlashClassName(const char* className)
return result;
}
/** Create a Java string from an ASCII or Latin-1 string */
jstring AndroidRuntime::NewStringLatin1(JNIEnv* env, const char* bytes) {
if (!bytes) return NULL;
int length = strlen(bytes);
jchar* buffer = (jchar *)alloca(length * sizeof(jchar));
if (!buffer) return NULL;
jchar* chp = buffer;
for (int i = 0; i < length; i++) {
*chp++ = *bytes++;
}
return env->NewString(buffer, length);
}
/*
* Start the Android runtime. This involves starting the virtual machine
* and calling the "static void main(String[] args)" method in the class