From 19ae9c79eed7c23ba1168e6ae54b909bc645660c Mon Sep 17 00:00:00 2001 From: uvlad7 Date: Mon, 16 Dec 2024 01:20:52 +0300 Subject: [PATCH] Update docs --- CHANGELOG.md | 2 +- README.md | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45c5826..101ca8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [0.1.0] - 2024-12-15 ### Added diff --git a/README.md b/README.md index 2856d88..2272491 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,12 @@ emoji_json = '{"grin": "😁", "heart": "😍", "rofl": "🤣"}' begin_pos, end_pos, = JsonScanner.scan(emoji_json, [["heart"]], false).first.first emoji_json.byteslice(begin_pos...end_pos) # => "\"😍\"" -emoji_json.force_encoding(Encoding::BINARY)[begin_pos...end_pos].force_encoding(Encoding::UTF_8) +# Note: most likely don't need `quirks_mode` option, unless you are using some old ruby +# with stdlib version of json gem or its old version. In new versions `quirks_mode` is default +JSON.parse(emoji_json.byteslice(begin_pos...end_pos), quirks_mode: true) +# => "😍" +# You can also do this +# emoji_json.force_encoding(Encoding::BINARY)[begin_pos...end_pos].force_encoding(Encoding::UTF_8) # => "\"😍\"" ```