Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.
/ jfx11u Public archive

Commit

Permalink
8210199: [linux / macOS] fileChooser can't handle emojis
Browse files Browse the repository at this point in the history
Backport-of: aebac072b1919e68f7732de929dc085d00c62e92
  • Loading branch information
Johan Vos committed Jun 9, 2021
1 parent 8af39d6 commit 259cd4f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,19 @@ JNIEXPORT jobject JNICALL Java_com_sun_glass_ui_gtk_GtkCommonDialogs__1showFileC
if (fnames_list_len > 0) {
jFileNames = env->NewObjectArray((jsize)fnames_list_len, jStringCls, NULL);
EXCEPTION_OCCURED(env);
const jmethodID bytesInit = env->GetMethodID(jStringCls, "<init>", "([B)V");
EXCEPTION_OCCURED(env);
for (guint i = 0; i < fnames_list_len; i++) {
filename = (char*)g_slist_nth(fnames_gslist, i)->data;
LOG1("Add [%s] into returned filenames\n", filename)
jfilename = env->NewStringUTF(filename);
int len = strlen(filename);
jbyteArray bytes = env->NewByteArray(len);
EXCEPTION_OCCURED(env);
env->SetByteArrayRegion(bytes, 0, len, (jbyte *)filename);
EXCEPTION_OCCURED(env);
jfilename = (jstring) env->NewObject(jStringCls, bytesInit, bytes);
EXCEPTION_OCCURED(env);
env->DeleteLocalRef(bytes);
EXCEPTION_OCCURED(env);
env->SetObjectArrayElement(jFileNames, (jsize)i, jfilename);
EXCEPTION_OCCURED(env);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,11 @@ -(void)extensionFilterChanged:(NSPopUpButton*)sender

static jobject convertNSURLtoFile(JNIEnv *env, NSURL *url)
{
LOG(" url: %s", [[url path] UTF8String]);
jstring path = (*env)->NewStringUTF(env, [[url path] UTF8String]);
#ifdef VERBOSE
NSLog(@" url: %@", [url path]);
#endif // VERBOSE
NSData *data = [[url path] dataUsingEncoding:NSUTF16LittleEndianStringEncoding];
jstring path = (*env)->NewString(env, (jchar *)[data bytes], data.length/2);

jobject ret = NULL;

Expand Down

1 comment on commit 259cd4f

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.