Skip to content

Inconsistent character encoding for serial.write() #75

@tkem

Description

@tkem

I noticed that the native writeSerial() on Android
https://github.com/xseignard/cordovarduino/blob/master/src/android/fr/drangies/cordova/serial/Serial.java#L284
uses getBytes(), which "encodes the string using the platform's default charset", which seems to always be UTF-8 on Android
https://developer.android.com/reference/java/nio/charset/Charset.html
while on Ubuntu the string argument is explicitly converted to Latin-1:
https://github.com/xseignard/cordovarduino/blob/master/src/ubuntu/serial.cpp#L94

AFAICS, cordovarduino's documentation does not state anything about character encodings, or how characters with charCode >= 128 will be handled by serial.write(). However, handling this differently depending on the platform may be surprising to users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions