Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
00434c93
Commit
00434c93
authored
Sep 15, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement correct width computation
parent
b12033fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
include/fmt/format.h
include/fmt/format.h
+23
-3
No files found.
include/fmt/format.h
View file @
00434c93
...
@@ -923,9 +923,29 @@ inline size_t compute_width(string_view s) {
...
@@ -923,9 +923,29 @@ inline size_t compute_width(string_view s) {
#if FMT_USE_TEXT
#if FMT_USE_TEXT
basic_memory_buffer
<
uint32_t
>
code_points
;
basic_memory_buffer
<
uint32_t
>
code_points
;
for
(
auto
cp
:
boost
::
text
::
make_to_utf32_range
(
s
))
code_points
.
push_back
(
cp
);
for
(
auto
cp
:
boost
::
text
::
make_to_utf32_range
(
s
))
code_points
.
push_back
(
cp
);
size_t
num_graphemes
=
0
;
size_t
width
=
0
;
for
(
auto
g
:
boost
::
text
::
graphemes
(
code_points
))
++
num_graphemes
;
for
(
auto
g
:
boost
::
text
::
graphemes
(
code_points
))
{
return
num_graphemes
;
auto
cp
=
*
g
.
begin
();
// Based on http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c by Markus Kuhn.
width
+=
1
+
(
cp
>=
0x1100
&&
(
cp
<=
0x115f
||
// Hangul Jamo init. consonants
cp
==
0x2329
||
// LEFT-POINTING ANGLE BRACKET〈
cp
==
0x232a
||
// RIGHT-POINTING ANGLE BRACKET 〉
// CJK ... Yi except Unicode Character “〿”:
(
cp
>=
0x2e80
&&
cp
<=
0xa4cf
&&
cp
!=
0x303f
)
||
(
cp
>=
0xac00
&&
cp
<=
0xd7a3
)
||
// Hangul Syllables
(
cp
>=
0xf900
&&
cp
<=
0xfaff
)
||
// CJK Compatibility Ideographs
(
cp
>=
0xfe10
&&
cp
<=
0xfe19
)
||
// Vertical Forms
(
cp
>=
0xfe30
&&
cp
<=
0xfe6f
)
||
// CJK Compatibility Forms
(
cp
>=
0xff00
&&
cp
<=
0xff60
)
||
// Fullwidth Forms
(
cp
>=
0xffe0
&&
cp
<=
0xffe6
)
||
// Fullwidth Forms
(
cp
>=
0x20000
&&
cp
<=
0x2fffd
)
||
// CJK
(
cp
>=
0x30000
&&
cp
<=
0x3fffd
)
||
// Miscellaneous Symbols and Pictographs + Emoticons:
(
cp
>=
0x1f300
&&
cp
<=
0x1f64f
)));
}
return
width
;
#else
#else
return
s
.
size
();
return
s
.
size
();
#endif // FMT_USE_TEXT
#endif // FMT_USE_TEXT
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment