# Width problem when using printf on chinese characters

**URL:** <https://discourse.julialang.org/t/width-problem-when-using-printf-on-chinese-characters/74124>\
**Category:** General Usage\
**Created:** [January 6, 2022, 8:44am UTC](https://discourse.julialang.org/t/width-problem-when-using-printf-on-chinese-characters/74124 "2022-01-06T08:44:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsjie](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jsjie/32/22477_2.png) [@jsjie](https://discourse.julialang.org/u/jsjie)\
**Post date:** [January 6, 2022, 8:44am UTC](https://discourse.julialang.org/t/width-problem-when-using-printf-on-chinese-characters/74124/1 "2022-01-06T08:44:19Z")

</div>

A Chinese character will normally displays as 2 ascii width, but the format string in printf will treat it as 1 character. This may result in inconsistent string width with the same format string.

This is a simple example:

```julia
using Printf
@printf("%-10s: 111\n", "aaa")
@printf("%-10s: 111\n", "一")

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 6, 2022, 1:44pm UTC](https://discourse.julialang.org/t/width-problem-when-using-printf-on-chinese-characters/74124/2 "2022-01-06T13:44:39Z")

</div>

> [@jsjie](#):
>
> A Chinese character will normally displays as 2 ascii width, but the format string in printf will treat it as 1 character. This may result in inconsistent string width with the same format string.

Should be fixed in ~~Julia 1.7~~ Julia 1.8? [use `textwidth` in Printf for `%s` and `%c` widths by stevengj · Pull Request #41085 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/pull/41085)

With Julia 1.8-dev, I get:

```julia
julia> @printf("%-10s: 111\n", "一")
一 : 111

julia> @printf("%-10s: 111\n", "aaa")
aaa : 111

```

(I thought this feature was merged for 1.7, but I guess it was merged right after the 1.7 feature freeze.)
