Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShareableObject unable to handle utf-8 key on Android #6220

Closed
hpsoar opened this issue Jul 7, 2024 · 1 comment · Fixed by #6373
Closed

ShareableObject unable to handle utf-8 key on Android #6220

hpsoar opened this issue Jul 7, 2024 · 1 comment · Fixed by #6373
Assignees
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snippet of code, snack or repo is provided

Comments

@hpsoar
Copy link

hpsoar commented Jul 7, 2024

Description

 for (size_t i = 0, size = data_.size(); i < size; i++) {
    obj.setProperty(
        rt, data_[i].first.c_str(), data_[i].second->getJSValue(rt));
  }

data_[i].first.c_str() can't handle utf-8.

the following code works:

  for (size_t i = 0, size = data_.size(); i < size; i++) {
      std::cout << "shareable" << data_[i].first.c_str() << std::endl;
      obj.setProperty(
        rt, jsi::PropNameID::forUtf8(rt, data_[i].first.c_str()), data_[i].second->getJSValue(rt));
  }

Steps to reproduce

when save the following data in SharedValue

{
"中文": 0,
"键值", 1,
}

I got something like the following when read:

{"���":0,"��":0}

Snack or a link to a repository

https://snack.expo.dev/NAmgJOBZPjyaxE2nLFZRf

Reanimated version

3.12.1

React Native version

0.74.84

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

Paper (Old Architecture)

Build type

Debug app & dev bundle

Device

Real device

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Repro provided A reproduction with a snippet of code, snack or repo is provided Platform: Android This issue is specific to Android labels Jul 7, 2024
@hpsoar
Copy link
Author

hpsoar commented Jul 7, 2024

the link provided works on Expo >= v50.
not work on Expo < v50.

@tomekzaw tomekzaw self-assigned this Aug 2, 2024
github-merge-queue bot pushed a commit that referenced this issue Aug 5, 2024
<!-- Thanks for submitting a pull request! We appreciate you spending
the time to work on these changes. Please follow the template so that
the reviewers can easily understand what the code changes affect. -->

## Summary

<!-- Explain the motivation for this PR. Include "Fixes #<number>" if
applicable. -->

Regarding this
[issue](#6220)
the PR solves it by creating a jsi key string from utf8.

Fixes #6220.

## Test plan

<!-- Provide a minimal but complete code snippet that can be used to
test out this change along with instructions how to run it and a
description of the expected behavior. -->

Tested on demo provided in issue mentioned above.

---------

Co-authored-by: Tomek Zawadzki <tomekzawadzki98@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: Android This issue is specific to Android Repro provided A reproduction with a snippet of code, snack or repo is provided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants