mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 11:09:05 +03: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
Notes:
sideshowbarker
2024-07-19 06:33:54 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/cc42d752094
@ -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 New Issue
Block a user