Proposal: Add list2str() and str2list()#4190
Closed
ichizok wants to merge 3 commits intovim:masterfrom
Closed
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4190 +/- ##
==========================================
- Coverage 79.34% 79.34% -0.01%
==========================================
Files 105 105
Lines 141277 141317 +40
==========================================
+ Hits 112095 112124 +29
- Misses 29182 29193 +11
Continue to review full report at Codecov.
|
Contributor
|
This pull-req is the part of #4059, which was closed.
list2str(list [, utf8])
* e.g. list2str([0xXXXX, 0xYYYY, 0xZZZZ], 1) == "\uXXXX\uYYYY\uZZZZ" (\uYYYY is a composing character)
str2list(expr [, utf8])
* e.g. str2list("\uXXXX\uYYYY\uZZZZ", 1) == [0xXXXX, 0xYYYY, 0xZZZZ] (\uYYYY is a composing character)
I had been wondering whether these functions are useful by themselves.
list2str() can be implemented with join() and map():
let str = join(map(list, {nr, val -> nr2char(val)}), '')
And str2list():
let list = map(split(str, '\zs'), {idx, val -> char2nr(val)})
So the question is whether this is used often enough to add a function
for?
…--
hundred-and-one symptoms of being an internet addict:
157. You fum through a magazine, you first check to see if it has a web
address.
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|
Contributor
Author
This cannot get unicode composing characters. Thus I propose to add |
janlazo
added a commit
to janlazo/neovim
that referenced
this pull request
Feb 21, 2020
Problem: char2nr() does not handle composing characters. Solution: Add str2list() and list2str(). (Ozaki Kiichi, closes vim/vim#4190) vim/vim@9d40128 'utf8' optional param is noop unlike Vim.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull-req is the part of #4059, which was closed.
list2str(list [, utf8])
str2list(expr [, utf8])