|
32 | 32 | #include "jni_elements.h"
|
33 | 33 | #include "jni_exception.h"
|
34 | 34 | #include "sqlite3_exception.h"
|
35 |
| -#include <utils/String16.h> |
| 35 | +//#include <utils/String16.h> |
36 | 36 |
|
37 | 37 | namespace sqlcipher {
|
38 |
| - |
| 38 | + |
39 | 39 | static jfieldID gWindowField;
|
40 | 40 | static jfieldID gBufferField;
|
41 | 41 | static jfieldID gSizeCopiedField;
|
@@ -323,13 +323,18 @@ LOG_WINDOW("Getting string for %d,%d from %p", row, column, window);
|
323 | 323 | if (type == FIELD_TYPE_STRING) {
|
324 | 324 | uint32_t size = field.data.buffer.size;
|
325 | 325 | if (size > 0) {
|
326 |
| -#if WINDOW_STORAGE_UTF8 |
327 |
| - // Pass size - 1 since the UTF8 is null terminated and we don't want a null terminator on the UTF16 string |
328 |
| - android::String16 utf16((char const *)window->offsetToPtr(field.data.buffer.offset), size - 1); |
329 |
| - return env->NewString((jchar const *)utf16.string(), utf16.size()); |
330 |
| -#else |
331 |
| - return env->NewString((jchar const *)window->offsetToPtr(field.data.buffer.offset), size / 2); |
332 |
| -#endif |
| 326 | + return env->NewString((jchar const*)window->offsetToPtr(field.data.buffer.offset), size); |
| 327 | +// #if WINDOW_STORAGE_UTF8 |
| 328 | + |
| 329 | +// // std::wstring_convert<std::codecvt<char16_t,char,std::mbstate_t>,char16_t> convert; |
| 330 | +// // std::u16string utf16 = convert.from_bytes(window->offsetToPtr(field.data.buffer.offset)); |
| 331 | + |
| 332 | +// // Pass size - 1 since the UTF8 is null terminated and we don't want a null terminator on the UTF16 string |
| 333 | +// android::String16 utf16((char const *)window->offsetToPtr(field.data.buffer.offset), size - 1); |
| 334 | +// return env->NewString((jchar const *)utf16.string(), utf16.size()); |
| 335 | +// #else |
| 336 | +// return env->NewString((jchar const *)window->offsetToPtr(field.data.buffer.offset), size / 2); |
| 337 | +// #endif |
333 | 338 | } else {
|
334 | 339 | return env->NewStringUTF("");
|
335 | 340 | }
|
@@ -404,26 +409,39 @@ LOG_WINDOW("Copying string for %d,%d from %p", row, column, window);
|
404 | 409 | if (type == FIELD_TYPE_STRING) {
|
405 | 410 | uint32_t size = field.data.buffer.size;
|
406 | 411 | if (size > 0) {
|
407 |
| -#if WINDOW_STORAGE_UTF8 |
408 |
| - // Pass size - 1 since the UTF8 is null terminated and we don't want a null terminator on the UTF16 string |
409 |
| - android::String16 utf16((char const *)window->offsetToPtr(field.data.buffer.offset), size - 1); |
410 |
| - int32_t strSize = utf16.size(); |
411 |
| - if (strSize > bufferSize || dst == NULL) { |
412 |
| - newArray = env->NewCharArray(strSize); |
413 |
| - env->SetCharArrayRegion(newArray, 0, strSize, (jchar const *)utf16.string()); |
414 |
| - } else { |
415 |
| - memcpy(dst, (jchar const *)utf16.string(), strSize * 2); |
416 |
| - } |
417 |
| - sizeCopied = strSize; |
418 |
| -#else |
419 |
| - sizeCopied = size/2 + size % 2; |
| 412 | + |
420 | 413 | if (size > bufferSize * 2 || dst == NULL) {
|
421 | 414 | newArray = env->NewCharArray(sizeCopied);
|
422 | 415 | memcpy(newArray, (jchar const *)window->offsetToPtr(field.data.buffer.offset), size);
|
423 | 416 | } else {
|
424 | 417 | memcpy(dst, (jchar const *)window->offsetToPtr(field.data.buffer.offset), size);
|
425 | 418 | }
|
426 |
| -#endif |
| 419 | + |
| 420 | + |
| 421 | +// #if WINDOW_STORAGE_UTF8 |
| 422 | + |
| 423 | +// // std::wstring_convert<std::codecvt<char16_t,char,std::mbstate_t>,char16_t> convert; |
| 424 | +// // std::u16string utf16 = convert.from_bytes(window->offsetToPtr(field.data.buffer.offset)); |
| 425 | + |
| 426 | +// // Pass size - 1 since the UTF8 is null terminated and we don't want a null terminator on the UTF16 string |
| 427 | +// android::String16 utf16((char const *)window->offsetToPtr(field.data.buffer.offset), size - 1); |
| 428 | +// int32_t strSize = utf16.size(); |
| 429 | +// if (strSize > bufferSize || dst == NULL) { |
| 430 | +// newArray = env->NewCharArray(strSize); |
| 431 | +// env->SetCharArrayRegion(newArray, 0, strSize, (jchar const *)utf16.string()); |
| 432 | +// } else { |
| 433 | +// memcpy(dst, (jchar const *)utf16.string(), strSize * 2); |
| 434 | +// } |
| 435 | +// sizeCopied = strSize; |
| 436 | +// #else |
| 437 | +// sizeCopied = size/2 + size % 2; |
| 438 | +// if (size > bufferSize * 2 || dst == NULL) { |
| 439 | +// newArray = env->NewCharArray(sizeCopied); |
| 440 | +// memcpy(newArray, (jchar const *)window->offsetToPtr(field.data.buffer.offset), size); |
| 441 | +// } else { |
| 442 | +// memcpy(dst, (jchar const *)window->offsetToPtr(field.data.buffer.offset), size); |
| 443 | +// } |
| 444 | +// #endif |
427 | 445 | }
|
428 | 446 | } else if (type == FIELD_TYPE_INTEGER) {
|
429 | 447 | int64_t value;
|
|
0 commit comments