public static void Main() { Byte[] bytes; // Unicode characters. Char[] chars = new Char[] { '\u0023', // # '\u0025', // % '\u03a0', // Pi '\u03a3' // Sigma }; UTF7Encoding utf7 = new UTF7Encoding(); int byteCount = utf7.GetByteCount(chars, 1, 2); bytes = new Byte[byteCount]; int bytesEncodedCount = utf7.GetBytes(chars, 1, 2, bytes, 0); Console.WriteLine( "{0} bytes used to encode characters.", bytesEncodedCount ); Console.Write("Encoded bytes: "); foreach (Byte b in bytes) { Console.Write("[{0}]", b); } Console.WriteLine(); }
public void PosTest4() { Char[] CHARS = { '!', '\"', '#', '$', '%', '&', '*', ';', '<', '=' }; UTF7Encoding utf7 = new UTF7Encoding(true); Assert.Equal(c_INT_OPTIONALCHARSLENTTH, utf7.GetByteCount(_ARRAY_OPTIONALCHARS, 0, c_INT_OPTIONALCHARSLENTTH)); }
public void NegTest2() { Assert.Throws <ArgumentOutOfRangeException>(() => { UTF7Encoding UTF7 = new UTF7Encoding(); UTF7.GetByteCount(_ARRAY_DIRECTCHARS, -1, 1); }); }
public void NegTest1() { Assert.Throws <ArgumentNullException>(() => { UTF7Encoding UTF7 = new UTF7Encoding(); UTF7.GetByteCount(null, 0, 1); }); }
public void NegTest1() { Assert.Throws<ArgumentNullException>(() => { UTF7Encoding UTF7 = new UTF7Encoding(); UTF7.GetByteCount(null, 0, 1); }); }
public void NegTest1() { string source = null; Assert.Throws<ArgumentNullException>(() => { UTF7Encoding UTF7 = new UTF7Encoding(); UTF7.GetByteCount(source); }); }
public void NegTest1() { string source = null; Assert.Throws <ArgumentNullException>(() => { UTF7Encoding UTF7 = new UTF7Encoding(); UTF7.GetByteCount(source); }); }
public void PosTest2() { Byte[] bytes; Char[] chars = new Char[] { }; UTF7Encoding UTF7 = new UTF7Encoding(); int byteCount = UTF7.GetByteCount(chars, 0, 0); bytes = new Byte[byteCount]; int bytesEncodedCount = UTF7.GetBytes(chars, 0, 0, bytes, 0); Assert.Equal(0, bytesEncodedCount); }
public void PosTest1() { Byte[] bytes; Char[] chars = new Char[] { '\u0023', '\u0025', '\u03a0', '\u03a3' }; UTF7Encoding UTF7 = new UTF7Encoding(); int byteCount = UTF7.GetByteCount(chars, 1, 2); bytes = new Byte[byteCount]; int bytesEncodedCount = UTF7.GetBytes(chars, 1, 2, bytes, 0); }
public void NegTest3() { Byte[] bytes; Char[] chars = new Char[] { '\u0023', '\u0025', '\u03a0', '\u03a3' }; UTF7Encoding UTF7 = new UTF7Encoding(); int byteCount = UTF7.GetByteCount(chars, 1, 2); bytes = new Byte[byteCount]; Assert.Throws<ArgumentOutOfRangeException>(() => { int bytesEncodedCount = UTF7.GetBytes(chars, -1, 2, bytes, 0); }); }
public static void Main() { // Unicode characters. Char[] chars = new Char[] { '\u0023', // # '\u0025', // % '\u03a0', // Pi '\u03a3' // Sigma }; UTF7Encoding utf7 = new UTF7Encoding(); int byteCount = utf7.GetByteCount(chars, 1, 2); Console.WriteLine( "{0} bytes needed to encode characters.", byteCount ); }
public void NegTest3() { Byte[] bytes; Char[] chars = new Char[] { '\u0023', '\u0025', '\u03a0', '\u03a3' }; UTF7Encoding UTF7 = new UTF7Encoding(); int byteCount = UTF7.GetByteCount(chars, 1, 2); bytes = new Byte[byteCount]; Assert.Throws <ArgumentOutOfRangeException>(() => { int bytesEncodedCount = UTF7.GetBytes(chars, -1, 2, bytes, 0); }); }
public static void Main() { // Create an instance of UTF7Encoding. UTF7Encoding u7 = new UTF7Encoding(true); // Create byte arrays from the same string containing the following characters: // Latin Small Letter Z (U+007A) // Latin Small Letter A (U+0061) // Combining Breve (U+0306) // Latin Small Letter AE With Acute (U+01FD) // Greek Small Letter Beta (U+03B2) String myStr = "za\u0306\u01FD\u03B2"; // Encode the string. byte[] myBArr = new byte[u7.GetByteCount(myStr)]; u7.GetBytes(myStr, 0, myStr.Length, myBArr, 0); // Decode the byte array. Console.WriteLine("The new string is: {0}", u7.GetString(myBArr, 0, myBArr.Length)); }
public void PosTest7() { UTF7Encoding utf7 = new UTF7Encoding(); Assert.Equal(c_INT_EMPTYlENGTH, utf7.GetByteCount(_ARRAY_EMPTY, 0, 0)); }
public void PosTest6() { UTF7Encoding utf7 = new UTF7Encoding(true); Assert.Equal(c_INT_SPECIALCHARSLENGTH, utf7.GetByteCount(_ARRAY_SPECIALCHARS, 0, _ARRAY_SPECIALCHARS.Length)); }
public void PosTest2() { UTF7Encoding utf7 = new UTF7Encoding(true); Assert.Equal(c_INT_DIRECTCHARSLENGTH, utf7.GetByteCount(_ARRAY_DIRECTCHARS, 0, c_INT_DIRECTCHARSLENGTH)); }
public void PosTest3() { UTF7Encoding utf7 = new UTF7Encoding(); Assert.NotEqual(c_INT_OPTIONALCHARSLENTTH, utf7.GetByteCount(_ARRAY_OPTIONALCHARS, 0, c_INT_OPTIONALCHARSLENTTH)); }
public void PosTest7() { UTF7Encoding utf7 = new UTF7Encoding(); Assert.Equal(c_INT_STRINGEMPTYlENGTH, utf7.GetByteCount(String.Empty)); }
public void PosTest6() { UTF7Encoding utf7 = new UTF7Encoding(true); Assert.Equal(c_INT_SPECIALCHARSLENGTH, utf7.GetByteCount(c_STRING_SPECIALCHARS)); }
public void PosTest1() { UTF7Encoding utf7 = new UTF7Encoding(); Assert.Equal(c_INT_DIRECTCHARSLENGTH, utf7.GetByteCount(c_STRING_DIRECTCHARS)); }
public void NegTest2() { Assert.Throws<ArgumentOutOfRangeException>(() => { UTF7Encoding UTF7 = new UTF7Encoding(); UTF7.GetByteCount(_ARRAY_DIRECTCHARS, -1, 1); }); }
public void PosTest4() { UTF7Encoding utf7 = new UTF7Encoding(true); Assert.Equal(c_INT_OPTIONALCHARSLENTTH, utf7.GetByteCount(c_STRING_OPTIONALCHARS)); }