mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:47:35 +00:00
LibC: Implement CODESET for langinfo
This commit is contained in:
parent
5ea1810ada
commit
8f9af4a582
4 changed files with 63 additions and 0 deletions
|
@ -12,6 +12,7 @@ set(LIBC_SOURCES
|
||||||
grp.cpp
|
grp.cpp
|
||||||
inttypes.cpp
|
inttypes.cpp
|
||||||
ioctl.cpp
|
ioctl.cpp
|
||||||
|
langinfo.cpp
|
||||||
libcinit.cpp
|
libcinit.cpp
|
||||||
libgen.cpp
|
libgen.cpp
|
||||||
link.cpp
|
link.cpp
|
||||||
|
|
27
Userland/Libraries/LibC/langinfo.cpp
Normal file
27
Userland/Libraries/LibC/langinfo.cpp
Normal 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));
|
||||||
|
}
|
||||||
|
}
|
20
Userland/Libraries/LibC/langinfo.h
Normal file
20
Userland/Libraries/LibC/langinfo.h
Normal 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
|
15
Userland/Libraries/LibC/nl_types.h
Normal file
15
Userland/Libraries/LibC/nl_types.h
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue