Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetUtf8RepresentationForScalarValue()

static int System.Text.Unicode.UnicodeHelpers.GetUtf8RepresentationForScalarValue ( uint scalar)
inlinestaticpackage

Definition at line 843 of file UnicodeHelpers.cs.

844 {
845 if (scalar <= 127)
846 {
847 return (byte)scalar;
848 }
849 if (scalar <= 2047)
850 {
851 byte b = (byte)(0xC0u | (scalar >> 6));
852 byte b2 = (byte)(0x80u | (scalar & 0x3Fu));
853 return (b2 << 8) | b;
854 }
855 if (scalar <= 65535)
856 {
857 byte b3 = (byte)(0xE0u | (scalar >> 12));
858 byte b4 = (byte)(0x80u | ((scalar >> 6) & 0x3Fu));
859 byte b5 = (byte)(0x80u | (scalar & 0x3Fu));
860 return (((b5 << 8) | b4) << 8) | b3;
861 }
862 byte b6 = (byte)(0xF0u | (scalar >> 18));
863 byte b7 = (byte)(0x80u | ((scalar >> 12) & 0x3Fu));
864 byte b8 = (byte)(0x80u | ((scalar >> 6) & 0x3Fu));
865 byte b9 = (byte)(0x80u | (scalar & 0x3Fu));
866 return (((((b9 << 8) | b8) << 8) | b7) << 8) | b6;
867 }

Referenced by System.Text.Encodings.Web.DefaultUrlEncoder.EscaperImplementation.EncodeUtf16(), System.Text.Encodings.Web.DefaultUrlEncoder.EscaperImplementation.EncodeUtf8(), System.Text.Encodings.Web.TextEncoder.EncodeUtf8Core(), and System.Text.Encodings.Web.TextEncoder.TryEncodeUnicodeScalarUtf8().