0

Using sprintf need a fill up a character https://www.compart.com/en/unicode/U+2500

On console unix:

php > echo sprintf("%'-7s", '');
-------

php > echo sprintf("%'─7s", '');
�7s

A sign "─" is cp437 dash.

I need result:

───────

TEST: https://3v4l.org/JsAv6

This works:

php > echo sprintf("─", '');
─

Example:

echo sprintf("%'-7s", 'a');
------a

using dash will not work:

php > echo sprintf("%'─7s", 'a');
�7s
Marin Sagovac
  • 3,932
  • 5
  • 23
  • 53
  • It's `"\xC4"` if you want it in that codepage, but your script is UTF-8 still. Also the display on the console is somewhat irrelevant unless the environment was also set to that charset. (You didn't explain enough on the whole context.) – mario Mar 24 '18 at 10:49
  • A dash sign is utf-8 and it is not possible print using sprintf() even when your try iconv to cp437 or utf-8. https://3v4l.org/HApnQ#output – Marin Sagovac Mar 24 '18 at 13:19
  • You can't use Unicode symbols as part of sprintfs´ syntax. Hencewhy didn't you try CP437 for the "dash" via `"%'\xC47s"`? It does [exist in that codepage](https://en.wikipedia.org/wiki/Box-drawing_character) as single-byte character. Isn't that your very question? – mario Mar 24 '18 at 15:18

0 Answers0