]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Console/TerminalDxe/Vtutf8.c
Update the copyright notice format
[mirror_edk2.git] / MdeModulePkg / Universal / Console / TerminalDxe / Vtutf8.c
index 286c937d42bd7f372722fb19da9bcbf90c411e1f..51cc093a41ad7b4ada7051e095609441e94da525 100644 (file)
@@ -1,8 +1,8 @@
-/**@file\r
-  Implementation translation among different code tyies.\r
+/** @file\r
+  Implementation of translation upon VT-UTF8.\r
 \r
-Copyright (c) 2006, Intel Corporation. <BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2006 - 2009, 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
 which accompanies this distribution.  The full text of the license may be found at\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -14,6 +14,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include "Terminal.h"\r
 \r
+/**\r
+  Translate all VT-UTF8 characters in the Raw FIFI into unicode characters,\r
+  and insert them into Unicode FIFO.\r
+\r
+  @param TerminalDevice          The terminal device.\r
+\r
+**/\r
 VOID\r
 VTUTF8RawDataToUnicode (\r
   IN  TERMINAL_DEV    *TerminalDevice\r
@@ -43,6 +50,15 @@ VTUTF8RawDataToUnicode (
   }\r
 }\r
 \r
+/**\r
+  Get one valid VT-UTF8 characters set from Raw Data FIFO.\r
+\r
+  @param  Utf8Device          The terminal device.\r
+  @param  Utf8Char            Returned valid VT-UTF8 characters set.\r
+  @param  ValidBytes          The count of returned VT-VTF8 characters.\r
+                              If ValidBytes is zero, no valid VT-UTF8 returned.\r
+\r
+**/\r
 VOID\r
 GetOneValidUtf8Char (\r
   IN  TERMINAL_DEV      *Utf8Device,\r
@@ -109,6 +125,9 @@ GetOneValidUtf8Char (
       break;\r
 \r
     case 2:\r
+      //\r
+      // two-byte utf8 char go on\r
+      //\r
       if ((Temp & 0xc0) == 0x80) {\r
 \r
         Utf8Char->Utf8_2[0] = Temp;\r
@@ -122,15 +141,20 @@ GetOneValidUtf8Char (
       break;\r
 \r
     case 3:\r
+      //\r
+      // three-byte utf8 char go on\r
+      //\r
       if ((Temp & 0xc0) == 0x80) {\r
 \r
         Utf8Char->Utf8_3[2 - Index] = Temp;\r
         Index++;\r
-        if (Index == 3) {\r
+        if (Index > 2) {\r
           FetchFlag = FALSE;\r
         }\r
       } else {\r
-\r
+        //\r
+        // reset *ValidBytes and Index to zero, let valid utf8 char search restart\r
+        //\r
         *ValidBytes = 0;\r
         Index       = 0;\r
       }\r
@@ -148,6 +172,21 @@ GetOneValidUtf8Char (
   return ;\r
 }\r
 \r
+/**\r
+  Translate VT-UTF8 characters into one Unicode character.\r
+\r
+  UTF8 Encoding Table\r
+  Bits per Character | Unicode Character Range | Unicode Binary  Encoding |    UTF8 Binary Encoding\r
+        0-7             |     0x0000 - 0x007F     |     00000000 0xxxxxxx        |   0xxxxxxx\r
+        8-11          |     0x0080 - 0x07FF       |     00000xxx xxxxxxxx        |   110xxxxx 10xxxxxx\r
+       12-16          |     0x0800 - 0xFFFF       |     xxxxxxxx xxxxxxxx        |   1110xxxx 10xxxxxx 10xxxxxx\r
+\r
+\r
+  @param  Utf8Char         VT-UTF8 character set needs translating.\r
+  @param  ValidBytes       The count of valid VT-UTF8 characters.\r
+  @param  UnicodeChar      Returned unicode character.\r
+\r
+**/\r
 VOID\r
 Utf8ToUnicode (\r
   IN  UTF8_CHAR       Utf8Char,\r
@@ -206,6 +245,22 @@ Utf8ToUnicode (
   return ;\r
 }\r
 \r
+/**\r
+  Translate one Unicode character into VT-UTF8 characters.\r
+\r
+  UTF8 Encoding Table\r
+  Bits per Character | Unicode Character Range | Unicode Binary  Encoding |    UTF8 Binary Encoding\r
+        0-7             |     0x0000 - 0x007F     |     00000000 0xxxxxxx        |   0xxxxxxx\r
+        8-11          |     0x0080 - 0x07FF       |     00000xxx xxxxxxxx        |   110xxxxx 10xxxxxx\r
+       12-16          |     0x0800 - 0xFFFF       |     xxxxxxxx xxxxxxxx        |   1110xxxx 10xxxxxx 10xxxxxx\r
+\r
+\r
+  @param  Unicode          Unicode character need translating.\r
+  @param  Utf8Char         Return VT-UTF8 character set.\r
+  @param  ValidBytes       The count of valid VT-UTF8 characters. If\r
+                           ValidBytes is zero, no valid VT-UTF8 returned.\r
+\r
+**/\r
 VOID\r
 UnicodeToUtf8 (\r
   IN  CHAR16      Unicode,\r
@@ -249,6 +304,16 @@ UnicodeToUtf8 (
   }\r
 }\r
 \r
+\r
+/**\r
+  Check if input string is valid VT-UTF8 string.\r
+\r
+  @param  TerminalDevice          The terminal device.\r
+  @param  WString                 The input string.\r
+\r
+  @retval EFI_SUCCESS             If all input characters are valid.\r
+\r
+**/\r
 EFI_STATUS\r
 VTUTF8TestString (\r
   IN  TERMINAL_DEV    *TerminalDevice,\r