String width limit #4

Closed
opened 2018-10-10 13:59:18 +00:00 by pimlie · 2 comments
pimlie commented 2018-10-10 13:59:18 +00:00 (Migrated from github.com)

It seems that when setting a string width the printed width could be lower then specified when a short input string is used.

For example:

$ printj '|%1$60s|' s:"hello" | wc -c
41
$ printj '|%1$60s|' s:"hello world, how are you ?" | wc -c
62
$ printj '|%1$60s|' s:"hello world, how are you ??" | wc -c
63

I would expect that the first and second statements would also return 63 characters?

--edit--
It seems thats because the padstr's are limited to 20 chars and there are 2 iterations? Could we maybe lengthen the pad strings a bit?

Or maybe even use String.repeat instead with a polyfill?

It seems that when setting a string width the printed width could be lower then specified when a short input string is used. For example: ```bash $ printj '|%1$60s|' s:"hello" | wc -c 41 $ printj '|%1$60s|' s:"hello world, how are you ?" | wc -c 62 $ printj '|%1$60s|' s:"hello world, how are you ??" | wc -c 63 ``` I would expect that the first and second statements would also return 63 characters? --edit-- It seems thats because the padstr's are limited to 20 chars and there are 2 iterations? Could we maybe lengthen the pad strings a bit? Or maybe even use String.repeat instead with a [polyfill](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat)?
SheetJSDev commented 2018-10-19 17:16:58 +00:00 (Migrated from github.com)

Just following up -- we published 1.2.1 with the fix prescribed in #5 and the results are consistent now. Thank you very much!

Just following up -- we published 1.2.1 with the fix prescribed in #5 and the results are consistent now. Thank you very much!
pimlie commented 2018-10-19 17:18:39 +00:00 (Migrated from github.com)

Great, thank you for the quick merge!

Great, thank you for the quick merge!
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/printj#4
No description provided.