String translation between React-Native and Java is Trimming

3
closed
nickwelp
nickwelp
Posted 1 month ago

String translation between React-Native and Java is Trimming #32412

I have a JS Uint8array that contains binary data, which is converted to a string and sent to Java which reads the string. These strings/byte arrays are made using protocol buffers. The string in JS is "R\u0000", with "\u0000" being a null code. When the string arrives in Java, it is only "R" and the \u0000 is stripped. The typecasting from JS to Java is stripping some data out.

I'm looking at using ReadableMap as a workaround.

System: OS: macOS 11.6 CPU: (8) x64 Apple M1 Memory: 20.20 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.0.0 - ~/.nvm/versions/node/v14.0.0/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v14.0.0/bin/yarn npm: 6.14.4 - ~/.nvm/versions/node/v14.0.0/bin/npm Watchman: Not Found Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0 Android SDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.7042882 Xcode: 13.0/13A233 - /usr/bin/xcodebuild Languages: Java: 15.0.2 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: ~0.63.4 => 0.63.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found (Use NPX, Expo, and react native modules)

github-actions[bot]
github-actions[bot]
Created 1 month ago
:warning: Missing Environment Information
:information_source: Your issue may be missing information about your development environment. You can obtain the missing information by running react-native info in a console.
nickwelp
nickwelp
Created 1 month ago

Enviromental info has been added.

nickwelp
nickwelp
Created 1 month ago

I developed a work around, encoding the null character and decoding it. It's worth mentioning in the Documentation that null characters are trimmed when going between react-native and java.