Mercurial > vim
comparison src/testdir/test_expr.vim @ 26197:2093cc976da8 v8.2.3630
patch 8.2.3630: printf() with %S does not handle multi-byte correctly
Commit: https://github.com/vim/vim/commit/d85fccdfed58108c4e0958d0b17c64690b5f073f
Author: presuku <presuku@users.noreply.github.com>
Date: Sat Nov 20 19:38:31 2021 +0000
patch 8.2.3630: printf() with %S does not handle multi-byte correctly
Problem: Printf() with %S does not handle multi-byte correctly.
Solution: Count cells instead of bytes. (closes https://github.com/vim/vim/issues/9169, closes https://github.com/vim/vim/issues/7486)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 20 Nov 2021 20:45:02 +0100 |
parents | c07b6c54146a |
children | ce6490cd6282 |
comparison
equal
deleted
inserted
replaced
26196:75bc457099c4 | 26197:2093cc976da8 |
---|---|
294 call assert_equal('abc ', printf('%-4s', 'abc')) | 294 call assert_equal('abc ', printf('%-4s', 'abc')) |
295 call assert_equal('abc ', printf('%-4S', 'abc')) | 295 call assert_equal('abc ', printf('%-4S', 'abc')) |
296 | 296 |
297 call assert_equal('🐍', printf('%.2S', '🐍🐍')) | 297 call assert_equal('🐍', printf('%.2S', '🐍🐍')) |
298 call assert_equal('', printf('%.1S', '🐍🐍')) | 298 call assert_equal('', printf('%.1S', '🐍🐍')) |
299 | |
300 call assert_equal('[ あいう]', printf('[%10.6S]', 'あいうえお')) | |
301 call assert_equal('[ あいうえ]', printf('[%10.8S]', 'あいうえお')) | |
302 call assert_equal('[あいうえお]', printf('[%10.10S]', 'あいうえお')) | |
303 call assert_equal('[あいうえお]', printf('[%10.12S]', 'あいうえお')) | |
299 | 304 |
300 call assert_equal('1%', printf('%d%%', 1)) | 305 call assert_equal('1%', printf('%d%%', 1)) |
301 endfunc | 306 endfunc |
302 | 307 |
303 function Test_printf_float() | 308 function Test_printf_float() |