Skip to content

Commit

Permalink
Merge pull request #55 from IgVelasco/feat/fix-utf8-encodedecode
Browse files Browse the repository at this point in the history
Fix UTF8 encoding and decoding for string messages
  • Loading branch information
IgVelasco authored Aug 30, 2024
2 parents be4f912 + 75c5f78 commit f3b5e1f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ Working on iOS and Android
## 1.0.1
Change dependency of device_info to device_info_plus

## 1.0.2
Fixed encode issue with special characters
5 changes: 3 additions & 2 deletions lib/helpers/bytes_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ abstract class BytesUtils {
Uint8List.fromList(value).buffer.asByteData().getInt8(0);

static Uint8List stringToBytesArray(String value) =>
Uint8List.fromList(value.codeUnits);
Uint8List.fromList(utf8.encode(value));

static int getInt64(List<int> value) =>
Uint8List.fromList(value).buffer.asByteData().getInt64(0, Endian.host);

static String getString(List<int> value) => utf8.decode(value);
static String getString(List<int> value) =>
utf8.decode(value, allowMalformed: true);

static List<int> getBytesRangeAsIntList(
Uint8List bytesList, int start, int bytesAmount) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: nearby_cross
description: Flutter plugin for Android and iOS to use Nearby Connections API and send messages between devices.
version: 1.0.1
version: 1.0.2
repository: https://github.com/IgVelasco/nearby_cross

environment:
Expand Down

0 comments on commit f3b5e1f

Please sign in to comment.