1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:47:34 +00:00

LibC: Implement CODESET for langinfo

This commit is contained in:
Tim Schumacher 2021-06-01 23:37:09 +02:00 committed by Andreas Kling
parent 5ea1810ada
commit 8f9af4a582
4 changed files with 63 additions and 0 deletions

View file

@ -12,6 +12,7 @@ set(LIBC_SOURCES
grp.cpp
inttypes.cpp
ioctl.cpp
langinfo.cpp
libcinit.cpp
libgen.cpp
link.cpp

View file

@ -0,0 +1,27 @@
/*
* Copyright (c) 2021, the SerenityOS developers
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <langinfo.h>
static const char* __nl_langinfo(nl_item item)
{
switch (item) {
case CODESET:
return "UTF-8";
default:
return "";
}
}
extern "C" {
char* nl_langinfo(nl_item item)
{
// POSIX states that returned strings should not be modified,
// so this cast is probably fine.
return const_cast<char*>(__nl_langinfo(item));
}
}

View file

@ -0,0 +1,20 @@
/*
* Copyright (c) 2021, the SerenityOS developers
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <nl_types.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
enum {
CODESET,
};
char* nl_langinfo(nl_item);
__END_DECLS

View file

@ -0,0 +1,15 @@
/*
* Copyright (c) 2021, the SerenityOS developers
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <sys/cdefs.h>
__BEGIN_DECLS
typedef int nl_item;
__END_DECLS