[Issue 23457] New: std.string.wrap has no policy on how it counts columns

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 4 13:18:48 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=23457

          Issue ID: 23457
           Summary: std.string.wrap has no policy on how it counts columns
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: Ajieskola at gmail.com

There's no hint in documentation of `std.string.wrap` whether it counts the
columns by code unit or by code point. Moreover, the function does not even
settle on one or the other. Example:

```D
// €€ €€
// €€
//
wrap("€€ €€ €€", 18).writeln;
// €€ €€ €€
//
wrap("€€ €€", 18, "€€ ").writeln;
```

These both should print the same result. While either result will do, I'm
inclined to think the result should be the one with all '€':s in the same line.
The purpose of the function is to fit characters in a certain space, and
characters take the same amount of space regardless of encoding.

--


More information about the Digitalmars-d-bugs mailing list