mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +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
1 changed files with 7 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue