29 Input/output library [input.output]

29.11 File systems [filesystems]

29.11.6 Class path [fs.class.path]

29.11.6.3 Conversions [fs.path.cvt]

29.11.6.3.2 Type and encoding conversions [fs.path.type.cvt]

The native encoding of an ordinary character string is the operating system dependent current encoding for pathnames ([fs.class.path]).
The native encoding for wide character strings is the implementation-defined execution wide-character set encoding ([lex.charset]).
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:
  • char: The encoding is the native ordinary encoding.
    The method of conversion, if any, is operating system dependent.
    [Note 1:
    For POSIX-based operating systems path​::​value_­type is char so no conversion from char value type arguments or to char value type return values is performed.
    For Windows-based operating systems, the native ordinary encoding is determined by calling a Windows API function.
    — end note]
    [Note 2:
    This results in behavior identical to other C and C++ standard library functions that perform file operations using ordinary character strings to identify paths.
    Changing this behavior would be surprising and error prone.
    — end note]
  • wchar_­t: The encoding is the native wide encoding.
    The method of conversion is unspecified.
    [Note 3:
    For Windows-based operating systems path​::​value_­type is wchar_­t so no conversion from wchar_­t value type arguments or to wchar_­t value type return values is performed.
    — end note]
  • char8_­t: The encoding is UTF-8.
    The method of conversion is unspecified.
  • char16_­t: The encoding is UTF-16.
    The method of conversion is unspecified.
  • char32_­t: The encoding is UTF-32.
    The method of conversion is unspecified.
If the encoding being converted to has no representation for source characters, the resulting converted characters, if any, are unspecified.
Implementations should not modify member function arguments if already of type path​::​value_­type.