mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
ls: Make column alignment Unicode-aware :^)
You can now have emojis in file names and they will line up correctly in "ls" output.
This commit is contained in:
parent
6cde7e4d20
commit
cc42d75209
|
@ -28,6 +28,7 @@
|
|||
#include <AK/QuickSort.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
|
@ -134,6 +135,12 @@ int print_escaped(const char* name)
|
|||
{
|
||||
int printed = 0;
|
||||
|
||||
Utf8View utf8_name(name);
|
||||
if (utf8_name.validate()) {
|
||||
printf("%s", name);
|
||||
return utf8_name.length_in_codepoints();
|
||||
}
|
||||
|
||||
for (int i = 0; name[i] != '\0'; i++) {
|
||||
if (isprint(name[i])) {
|
||||
putchar(name[i]);
|
||||
|
|
Loading…
Reference in a new issue