Limit spellcheck feedback to approximately 10 MB.
[chromium-blink-merge.git] / base / android / jni_string.h
blob09e85f306f0c7eae9e3c33445af0cfbf6eadf4cf
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_ANDROID_JNI_STRING_H_
6 #define BASE_ANDROID_JNI_STRING_H_
8 #include <jni.h>
9 #include <string>
11 #include "base/android/scoped_java_ref.h"
12 #include "base/base_export.h"
13 #include "base/strings/string_piece.h"
15 namespace base {
16 namespace android {
18 // Convert a Java string to UTF8. Returns a std string.
19 BASE_EXPORT void ConvertJavaStringToUTF8(JNIEnv* env,
20 jstring str,
21 std::string* result);
22 BASE_EXPORT std::string ConvertJavaStringToUTF8(JNIEnv* env, jstring str);
23 BASE_EXPORT std::string ConvertJavaStringToUTF8(const JavaRef<jstring>& str);
24 BASE_EXPORT std::string ConvertJavaStringToUTF8(JNIEnv* env,
25 const JavaRef<jstring>& str);
27 // Convert a std string to Java string.
28 BASE_EXPORT ScopedJavaLocalRef<jstring> ConvertUTF8ToJavaString(
29 JNIEnv* env,
30 const base::StringPiece& str);
32 // Convert a Java string to UTF16. Returns a string16.
33 BASE_EXPORT void ConvertJavaStringToUTF16(JNIEnv* env,
34 jstring str,
35 string16* result);
36 BASE_EXPORT string16 ConvertJavaStringToUTF16(JNIEnv* env, jstring str);
37 BASE_EXPORT string16 ConvertJavaStringToUTF16(const JavaRef<jstring>& str);
38 BASE_EXPORT string16 ConvertJavaStringToUTF16(JNIEnv* env,
39 const JavaRef<jstring>& str);
41 // Convert a string16 to a Java string.
42 BASE_EXPORT ScopedJavaLocalRef<jstring> ConvertUTF16ToJavaString(
43 JNIEnv* env,
44 const base::StringPiece16& str);
46 } // namespace android
47 } // namespace base
49 #endif // BASE_ANDROID_JNI_STRING_H_