]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/LibC/Locale/multibyte_Utf8.c
StdLib: Clarify and improve comments.
[mirror_edk2.git] / StdLib / LibC / Locale / multibyte_Utf8.c
index ffe3dee231ca203b9e448a827b77f82ae75c4761..55f4802b16c2b13374ab70fe717a7a3f31321194 100644 (file)
@@ -1,4 +1,5 @@
 /** @file\r
+  Copyright (c) 2016, Daryl McDaniel. All rights reserved.<BR>\r
   Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -16,7 +17,7 @@
 #include  <sys/types.h>\r
 #include  <limits.h>\r
 \r
-typedef      int      ch_UCS4;\r
+typedef int      ch_UCS4;\r
 \r
 static  mbstate_t     LocalConvState = {0};\r
 \r
@@ -79,7 +80,7 @@ ProcessOneByte(unsigned char ch, mbstate_t *ps)
     // We are in an invalid state\r
     ps->A = 0;    // Initial State\r
   }\r
-  ps->C[ps->A] = ch;  // Save the current character\r
+  ps->C[ps->A] = ch;  // Save the current byte\r
   Mask = utf8_code_length[ch];\r
 \r
   if(ps->A == 0) {    // Initial State.  First byte of sequence.\r
@@ -89,7 +90,7 @@ ProcessOneByte(unsigned char ch, mbstate_t *ps)
       case 0:                       // State 0, Code 0\r
         errno = EILSEQ;\r
         RetVal = -1;\r
-        ps->E = 1;        // Consume this character\r
+        ps->E = 1;        // Consume this byte\r
         break;\r
       case 1:                       // State 0, Code 1\r
         // ASCII-7 Character\r
@@ -116,7 +117,7 @@ ProcessOneByte(unsigned char ch, mbstate_t *ps)
             ps->A = 0;      // Next state is State-0\r
             RetVal = 2;\r
           }\r
-          else {    // This isn't the last character, get more.  State 1, Code 3 or 4\r
+          else {    // This isn't the last byte, get more.  State 1, Code 3 or 4\r
             ps->A = 2;\r
             RetVal = -2;\r
           }\r
@@ -158,12 +159,12 @@ ProcessOneByte(unsigned char ch, mbstate_t *ps)
             errno = EILSEQ;\r
             ps->A = 0;\r
             RetVal = -1;\r
-            ps->E = 4;      // Can't happen, but consume this character anyway\r
+            ps->E = 4;      // Can't happen, but consume this byte anyway\r
           }\r
           break;\r
       }\r
     }\r
-    else {                // Invalid surrogate character\r
+    else {                // Invalid surrogate byte\r
       errno = EILSEQ;\r
       ps->A = 0;          // Next is State-0\r
       RetVal = -1;\r
@@ -287,7 +288,8 @@ OneWcToMcLen(const wchar_t InCh)
 \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
+    @param[out]   NumChar   Pointer to where to store the number of wide characters\r
+                            consumed, 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
@@ -961,8 +963,8 @@ wcsrtombs(
     @return   If a wide character is encountered that does not correspond to a\r
               valid multibyte character, the wcstombs function returns\r
               (size_t)(-1). Otherwise, the wcstombs function returns the number\r
-              of bytes modified, not including a terminating null character,\r
-              if any.\r
+              of bytes in the resulting multibyte character sequence,\r
+              not including the terminating null character (if any).\r
 \r
     Declared in: stdlib.h\r
 **/\r