Revision: 17696
          http://sourceforge.net/p/edk2/code/17696
Author:   jljusten
Date:     2015-06-23 23:34:28 +0000 (Tue, 23 Jun 2015)
Log Message:
-----------
BaseTools/UniClassObject: Support UTF-8 string data in .uni files

This allows .uni input files to be encoded with UTF-8. Today, we only
support UTF-16 encoding.

The strings are still converted to UCS-2 data for use in EDK II
modules. (This is the only unicode character format supported by UEFI
and EDK II.)

Although UTF-8 would allow any UCS-4 character to be present in the
source file, we restrict the entire file to the UCS-2 range.
(Including comments.) This allows the files to be converted to UTF-16
if needed.

v2:
 * Drop .utf8 extension. Use .uni file for UTF-8 data (mdkinney)
 * Merge in 'BaseTools/UniClassObject: Verify string data is 16-bit'
   commit

v3:
 * Restrict the entire file's characters (including comments) to the
   UCS-2 range in addition to string data. (mdkinney)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Michael D Kinney <[email protected]>
Reviewed-by: Yingke Liu <[email protected]>

Modified Paths:
--------------
    trunk/edk2/BaseTools/Source/Python/AutoGen/UniClassObject.py

Modified: trunk/edk2/BaseTools/Source/Python/AutoGen/UniClassObject.py
===================================================================
--- trunk/edk2/BaseTools/Source/Python/AutoGen/UniClassObject.py        
2015-06-23 23:34:22 UTC (rev 17695)
+++ trunk/edk2/BaseTools/Source/Python/AutoGen/UniClassObject.py        
2015-06-23 23:34:28 UTC (rev 17696)
@@ -297,9 +297,12 @@
             EdkLogger.Error("build", FILE_OPEN_FAILURE, ExtraData=File)
 
         #
-        # We currently only support UTF-16
+        # Detect Byte Order Mark at beginning of file.  Default to UTF-8
         #
-        Encoding = 'utf-16'
+        Encoding = 'utf-8'
+        if (FileIn.startswith(codecs.BOM_UTF16_BE) or
+            FileIn.startswith(codecs.BOM_UTF16_LE)):
+            Encoding = 'utf-16'
 
         self.VerifyUcs2Data(FileIn, FileName, Encoding)
 


------------------------------------------------------------------------------
Monitor 25 network devices or servers for free with OpManager!
OpManager is web-based network management software that monitors 
network devices and physical & virtual servers, alerts via email & sms 
for fault. Monitor 25 devices for free with no restriction. Download now
http://ad.doubleclick.net/ddm/clk/292181274;119417398;o
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to