www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23457] New: std.string.wrap has no policy on how it counts

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 puremagic.com
          Reporter: Ajieskola 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.

--
Nov 04 2022