This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
system_encoded_string() and generic_system_encoded_string() member functions
of std::filesystem::path are misnamedSection: 31.12.6.1 [fs.class.path.general], 31.12.6.3.2 [fs.path.type.cvt], 31.12.6.5.6 [fs.path.native.obs], 31.12.6.5.7 [fs.path.generic.obs], D.22.2 [depr.fs.path.obs] Status: New Submitter: Tom Honermann Opened: 2026-01-11 Last modified: 2026-01-18
Priority: Not Prioritized
View all issues with New status.
Discussion:
Addresses US 189-304
Thesystem_encoded_string() and generic_system_encoded_string() member functions of
std::filesystem::path are misnamed. These functions were added as renamed versions of
string() and generic_string() respectively by P2319R5 ("Prevent path
presentation problems"). The original function names are now deprecated.
The C++ standard does not define "system encoding" and casual use of such a term is at best
ambiguous. In common language, one might expect the "system encoding" to correspond to the
environment encoding (for which std::text_encoding::environment() provides a definition)
or the encoding of the current locale. However, neither of these encodings corresponds to
the encoding these functions are expected to use. 31.12.6.3.2 [fs.path.type.cvt] defines
"native encoding" and, for char-based filesystem paths, states (in a note) that
"For Windows-based operating systems, the native ordinary encoding is determined by calling
a Windows API function." It is not specified which Windows API function is consulted, but
existing implementations call AreFileApisANSI() to choose between the Active Code Page
(CP_ACP) and the OEM Code Page (CP_OEMCP). Microsoft's implementation also checks for
a thread-local locale and, if the locale encoding is UTF-8, prefers that (CP_UTF8) over
either of the other two.
Proposed resolution:
This wording is relative to N5032.
Modify 31.12.6.1 [fs.class.path.general], class path synopsis, as indicated:
namespace std::filesystem {
class path {
public:
[…]
// 31.12.6.5.6 [fs.path.native.obs], native format observers
[…]
std::string display_string() const;
std::string systemnative_encoded_string() const;
std::wstring wstring() const;
[…]
// 31.12.6.5.7 [fs.path.generic.obs], generic format observers
[…]
std::string generic_display_string() const;
std::string generic_systemnative_encoded_string() const;
std::wstring generic_wstring() const;
[…]
};
}
Modify 31.12.6.3.2 [fs.path.type.cvt] as indicated:
-2- For member function arguments that take character sequences representing paths and for member functions returning strings, value type and encoding conversion is performed if the value type of the argument or return value differs from
path::value_type. For the argument or return value, the method of conversion and the encoding to be converted to is determined by its value type:
(2.1) —
[Note 1: For POSIX-based operating systemschar: The encoding is the native ordinary encoding. The method of conversion, if any, is operating system dependent.path::value_typeischarso no conversion fromcharvalue type arguments or tocharvalue type return values is performed. For Windows-based operating systems, the native ordinary encoding is determined bycalling a Windows API functionthe current locale encoding and the WindowsAreFileApisANSIfunction. — end note] […](2.2) — […]
[…]
Modify 31.12.6.5.6 [fs.path.native.obs] as indicated:
std::stringsystemnative_encoded_string() const; std::wstring wstring() const; std::u8string u8string() const; std::u16string u16string() const; std::u32string u32string() const;-7- Returns:
-8- Remarks: Conversion, if any, is performed as specified by 31.12.6.3 [fs.path.cvt].native().
Modify 31.12.6.5.7 [fs.path.generic.obs] as indicated:
std::string generic_systemnative_encoded_string() const; std::wstring generic_wstring() const; std::u8string generic_u8string() const; std::u16string generic_u16string() const; std::u32string generic_u32string() const;-5- Returns: The pathname in the generic format.
-6- Remarks: Conversion, if any, is specified by 31.12.6.3 [fs.path.cvt].
Modify D.22.2 [depr.fs.path.obs] as indicated:
std::string string() const;-2- Returns:
.systemnative_encoded_string()std::string generic_string() const;-3- Returns:
generic_.systemnative_encoded_string()