Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Add list2str() and str2list() #4190

Closed
wants to merge 3 commits into from

Conversation

ichizok
Copy link
Contributor

@ichizok ichizok commented Mar 30, 2019

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)

@codecov-io
Copy link

Codecov Report

Merging #4190 into master will decrease coverage by <.01%.
The diff coverage is 75%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/evalfunc.c 88.65% <75%> (-0.1%) ⬇️
src/netbeans.c 27.21% <0%> (-0.3%) ⬇️
src/ex_cmds.c 81.68% <0%> (-0.25%) ⬇️
src/ex_cmds2.c 84.89% <0%> (-0.1%) ⬇️
src/window.c 83.05% <0%> (-0.04%) ⬇️
src/gui.c 58.46% <0%> (ø) ⬆️
src/os_unix.c 59.2% <0%> (+0.04%) ⬆️
src/getchar.c 75.46% <0%> (+0.04%) ⬆️
src/channel.c 83.42% <0%> (+0.07%) ⬆️
src/gui_gtk_x11.c 49.45% <0%> (+0.34%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e73f911...932e775. Read the comment docs.

@brammool
Copy link
Contributor

brammool commented Mar 30, 2019 via email

@ichizok
Copy link
Contributor Author

ichizok commented Mar 31, 2019

let list = map(split(str, '\zs'), {idx, val -> char2nr(val)})

This cannot get unicode composing characters.
e.g. when str = "a\u0300", list contains 0x61 (= 'a') only.

Thus I propose to add str2list() which can get all constituent characters, and the inverse function list2str().
Regarding list2str(), although join(map(...)) can create string including composing characters, it is convenient to be one function corresponding with str2list().

@brammool brammool closed this in 9d40128 Apr 6, 2019
@ichizok ichizok deleted the feature/str2list branch April 6, 2019 11:57
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants