0
0
mirror of https://github.com/vim/vim.git synced 2025-10-21 08:24:06 -04:00

patch 9.1.1144: no way to create raw strings from a blob

Problem:  no way to create raw strings from a blob
Solution: support the "encoding": "none" option
          to create raw strings (which may be invalid!)
          (Bakudankun)

closes: #16666

Signed-off-by: Bakudankun <bakudankun@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Bakudankun
2025-02-23 20:29:21 +01:00
committed by Christian Brabandt
parent e0029daa35
commit b3854bfc54
4 changed files with 25 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
*builtin.txt* For Vim version 9.1. Last change: 2025 Feb 17
*builtin.txt* For Vim version 9.1. Last change: 2025 Feb 23
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1309,10 +1309,14 @@ blob2str({blob} [, {options}]) *blob2str()*
items:
encoding Decode the bytes in {blob} using this
encoding. The value is a |String|. See
|encoding-names| for the supported values.
|encoding-names| for the supported values
(plus the special value "none").
*E1515*
An error is given and an empty List is returned if
an invalid byte sequence is encountered in {blob},
When current 'encoding' is "utf-8", an error is given and an
empty List is returned if an invalid byte sequence is
encountered in {blob}. To suppress this validation and get
potentially invalid string, set "encoding" in {options} to
"none".
Returns an empty List if blob is empty.
@@ -10645,7 +10649,8 @@ str2blob({list} [, {options}]) *str2blob()*
The argument {options} is a |Dict| and supports the following
items:
encoding Encode the characters using this encoding.
encoding Convert the characters using this encoding
before making the Blob.
The value is a |String|. See |encoding-names|
for the supported values.