]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/Include/stdlib.h
StdLib/Include: Minor changes in preparation for Interactive I/O (TTY) functionality.
[mirror_edk2.git] / StdLib / Include / stdlib.h
index 1166847867295764ed9e9d5a963ff32289f784f1..0b9dfd34b03ab82546fbf5aa5ceceb21170b52b4 100644 (file)
                                      char ** __restrict endptr);\r
   @endverbatim\r
 \r
-  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials are licensed and made available under\r
   the terms and conditions of the BSD License that accompanies this distribution.\r
   The full text of the license may be found at\r
@@ -166,8 +166,11 @@ typedef struct {
     maximum number of bytes in a multibyte character for the extended character\r
     set specified by the current locale (category LC_CTYPE), which is never\r
     greater than MB_LEN_MAX.\r
+\r
+    Since UEFI only supports the Unicode Base Multilingual Plane (BMP),\r
+    correctly formed characters will only produce 1, 2, or 3-byte UTF-8 characters.\r
 **/\r
-#define MB_CUR_MAX  2\r
+#define MB_CUR_MAX  3\r
 \r
 /** Maximum number of functions that can be registered by atexit.\r
 \r
@@ -845,7 +848,7 @@ size_t  mbstowcs(wchar_t * __restrict Dest, const char * __restrict Src, size_t
 \r
     @param[out]   Dest    Pointer to the array to receive the converted string.\r
     @param[in]    Src     Pointer to the string to be converted.\r
-    @param[in]    Limit   Maximum number of elements to be written to Dest.\r
+    @param[in]    Limit   Maximum number of bytes to be written to Dest.\r
 \r
     @return   If a wide character is encountered that does not correspond to a\r
               valid multibyte character, the wcstombs function returns\r
@@ -855,7 +858,7 @@ size_t  mbstowcs(wchar_t * __restrict Dest, const char * __restrict Src, size_t
 **/\r
 size_t  wcstombs(char * __restrict Dest, const wchar_t * __restrict Src, size_t Limit);\r
 \r
-/* ################  Miscelaneous functions for *nix compatibility  ########## */\r
+/* ##############  Miscelaneous functions for *nix compatibility  ########## */\r
 \r
 /** The realpath() function shall derive, from the pathname pointed to by\r
     file_name, an absolute pathname that names the same file, whose resolution\r
@@ -890,6 +893,59 @@ const char * getprogname(void);
 **/\r
 void setprogname(const char *progname);\r
 \r
+/* ###############  Functions specific to this implementation  ############# */\r
+\r
+/*  Determine the number of bytes needed to represent a Wide character\r
+    as a MBCS character.\r
+\r
+    A single wide character may convert into a one, two, three, or four byte\r
+    narrow (MBCS or UTF-8) character.  The number of MBCS bytes can be determined\r
+    as follows.\r
+\r
+    If WCS char      < 0x00000080      One Byte\r
+    Else if WCS char < 0x0000D800      Two Bytes\r
+    Else                               Three Bytes\r
+\r
+    Since UEFI only supports the Unicode Base Multilingual Plane (BMP),\r
+    Four-byte characters are not supported.\r
+\r
+    @param[in]    InCh      Wide character to test.\r
+\r
+    @retval     -1      Improperly formed character\r
+    @retval      0      InCh is 0x0000\r
+    @retval     >0      Number of bytes needed for the MBCS character\r
+*/\r
+int\r
+EFIAPI\r
+OneWcToMcLen(const wchar_t InCh);\r
+\r
+/*  Determine the number of bytes needed to represent a Wide character string\r
+    as a MBCS string of given maximum length.  Will optionally return the number\r
+    of wide characters that would be consumed.\r
+\r
+    @param[in]    Src       Pointer to a wide character string.\r
+    @param[in]    Limit     Maximum number of bytes the converted string may occupy.\r
+    @param[out]   NumChar   Pointer to where to store the number of wide characters, or NULL.\r
+\r
+    @return     The number of bytes required to convert Src to MBCS,\r
+                not including the terminating NUL.  If NumChar is not NULL, the number\r
+                of characters represented by the return value will be written to\r
+                where it points.\r
+**/\r
+size_t\r
+EFIAPI\r
+EstimateWtoM(const wchar_t * Src, size_t Limit, size_t *NumChar);\r
+\r
+/** Determine the number of characters in a MBCS string.\r
+\r
+    @param[in]    Src     The string to examine\r
+\r
+    @return   The number of characters represented by the MBCS string.\r
+**/\r
+size_t\r
+EFIAPI\r
+CountMbcsChars(const char *Src);\r
+\r
 __END_DECLS\r
 \r
 #endif  /* _STDLIB_H */\r