Reviewed-by: Liming Gao <[email protected]> > -----Original Message----- > From: Wu, Hao A > Sent: Friday, October 19, 2018 11:06 AM > To: [email protected] > Cc: Wu, Hao A <[email protected]>; Bin . Lain <[email protected]>; > Yao, Jiewen <[email protected]>; Kinney, Michael D > <[email protected]>; Gao, Liming <[email protected]> > Subject: [PATCH] MdePkg/BaseLib: AsciiStrToUnicodeStr(S) not handle EASCII > properly > > REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1262 > > Current implementation of BaseLib APIs: > > AsciiStrToUnicodeStr() > AsciiStrToUnicodeStrS() > AsciiStrnToUnicodeStrS() > > do not handle EASCII properly. > > More specifically, if the value of ASCII character is larger than 0x7F, > then the converted Unicode character will have all '1's in the higher 8 > bits. > > An example: > 0xC9 => 0xFFC9 (current implementations) > and it should be: > 0xC9 => 0x00C9 > > This commit will address this issue. > > Cc: Bin.Lain <[email protected]> > Cc: Jiewen Yao <[email protected]> > Cc: Michael D Kinney <[email protected]> > Cc: Liming Gao <[email protected]> > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Hao Wu <[email protected]> > --- > MdePkg/Library/BaseLib/SafeString.c | 4 ++-- > MdePkg/Library/BaseLib/String.c | 2 +- > 2 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/MdePkg/Library/BaseLib/SafeString.c > b/MdePkg/Library/BaseLib/SafeString.c > index 29310889ca..417497cbc9 100644 > --- a/MdePkg/Library/BaseLib/SafeString.c > +++ b/MdePkg/Library/BaseLib/SafeString.c > @@ -2932,7 +2932,7 @@ AsciiStrToUnicodeStrS ( > // Convert string > // > while (*Source != '\0') { > - *(Destination++) = (CHAR16)*(Source++); > + *(Destination++) = (CHAR16)(UINT8)*(Source++); > } > *Destination = '\0'; > > @@ -3045,7 +3045,7 @@ AsciiStrnToUnicodeStrS ( > // Convert string > // > while ((*Source != 0) && (SourceLen > 0)) { > - *(Destination++) = (CHAR16)*(Source++); > + *(Destination++) = (CHAR16)(UINT8)*(Source++); > SourceLen--; > (*DestinationLength)++; > } > diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/String.c > index cb90774c86..e6df12797d 100644 > --- a/MdePkg/Library/BaseLib/String.c > +++ b/MdePkg/Library/BaseLib/String.c > @@ -1746,7 +1746,7 @@ AsciiStrToUnicodeStr ( > > ReturnValue = Destination; > while (*Source != '\0') { > - *(Destination++) = (CHAR16) *(Source++); > + *(Destination++) = (CHAR16)(UINT8) *(Source++); > } > // > // End the Destination with a NULL. > -- > 2.12.0.windows.1
_______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

