public AsciiBox boxString(String name, String data, int charWidth) {
        Objects.requireNonNull(data);
        // Convert dos2unix as that messes with box rendering
        data = data.replaceAll("\r\n", "\n");
        data = data.replaceAll("\t", "  ");
        AsciiBox rawBox = new AsciiBox(this, data);
        int longestLine = rawBox.width();
        if (charWidth < longestLine) {
            LOGGER.trace("Overflow by {} chars", longestLine - charWidth);
            charWidth = longestLine + borderWidth + borderWidth;
        }
        StringBuilder boxedString = new StringBuilder();
        int namePadding = (Math.max(charWidth - name.length() - borderWidth - extraNameCharIndent - borderWidth, 0));
        boxedString.append(boxSet.upperLeftCorner).append(boxSet.horizontalLine).append(name).append(StringUtils.repeat(boxSet.horizontalLine, namePadding)).append(boxSet.upperRightCorner).append(newLine);
        // Name of the header stretches the box so we align to that
        charWidth = borderWidth + extraNameCharIndent + name.length() + namePadding + borderWidth;
        for (String line : rawBox.lines()) {
            int linePadding = charWidth - Hex.boxLineOverheat - line.length();
            if (linePadding < 0) {
                linePadding = 0;
            }
            int frontPadding = (int) Math.floor(linePadding / 2.0);
            int backPadding = (int) Math.ceil(linePadding / 2.0);
            boxedString.append(boxSet.verticalLine).append(StringUtils.repeat(emptyPadding, frontPadding)).append(line).append(StringUtils.repeat(emptyPadding, backPadding)).append(boxSet.verticalLine).append(newLine);
        }
        int bottomPadding = namePadding + name.length() + extraNameCharIndent;
        boxedString.append(boxSet.lowerLeftCorner).append(StringUtils.repeat(boxSet.horizontalLine, bottomPadding)).append(boxSet.lowerRightCorner);
        return new AsciiBox(this, boxedString.toString());
    }
BoxString boxes a newline separated string into a beautiful box

@param name      of the box (can be empty)
@param data      data to be boxed
@param charWidth desired width
@return boxed data
plc4j/spi/src/main/java/org/apache/plc4x/java/spi/utils/ascii/AsciiBoxWriter.java