UTF7Encoding.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. /*
  2. * UTF7Encoding.cs - Implementation of the
  3. * "System.Text.UTF7Encoding" class.
  4. *
  5. * Copyright (c) 2002 Southern Storm Software, Pty Ltd
  6. * Copyright (c) 2003, Novell, Inc.
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining
  9. * a copy of this software and associated documentation files (the "Software"),
  10. * to deal in the Software without restriction, including without limitation
  11. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  12. * and/or sell copies of the Software, and to permit persons to whom the
  13. * Software is furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included
  16. * in all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  21. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  22. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  23. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  24. * OTHER DEALINGS IN THE SOFTWARE.
  25. */
  26. namespace System.Text
  27. {
  28. using System;
  29. [Serializable]
  30. #if ECMA_COMPAT
  31. internal
  32. #else
  33. public
  34. #endif
  35. class UTF7Encoding : Encoding
  36. {
  37. // Magic number used by Windows for UTF-7.
  38. internal const int UTF7_CODE_PAGE = 65000;
  39. // Internal state.
  40. private bool allowOptionals;
  41. // Encoding rule table for 0x00-0x7F.
  42. // 0 - full encode, 1 - direct, 2 - optional, 3 - encode plus.
  43. private static readonly byte[] encodingRules = {
  44. 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, // 00
  45. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 10
  46. 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 3, 1, 1, 1, 1, // 20
  47. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, // 30
  48. 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 40
  49. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 2, 2, 2, // 50
  50. 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 60
  51. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 0, 0, // 70
  52. };
  53. // Characters to use to encode 6-bit values in base64.
  54. private const String base64Chars =
  55. "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  56. // Map bytes in base64 to 6-bit values.
  57. private static readonly sbyte[] base64Values = {
  58. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00
  59. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10
  60. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, 63, // 20
  61. 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, // 30
  62. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, // 40
  63. 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, // 50
  64. 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, // 60
  65. 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, -1, // 70
  66. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 80
  67. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 90
  68. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // A0
  69. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // B0
  70. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // C0
  71. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // D0
  72. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // E0
  73. -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // F0
  74. };
  75. // Constructors.
  76. public UTF7Encoding ()
  77. : this (false)
  78. {
  79. }
  80. public UTF7Encoding (bool allowOptionals)
  81. : base (UTF7_CODE_PAGE)
  82. {
  83. this.allowOptionals = allowOptionals;
  84. body_name = "utf-7";
  85. encoding_name = "Unicode (UTF-7)";
  86. header_name = "utf-7";
  87. is_mail_news_display = true;
  88. is_mail_news_save = true;
  89. web_name = "utf-7";
  90. windows_code_page = UnicodeEncoding.UNICODE_CODE_PAGE;
  91. }
  92. // Internal version of "GetByteCount" that can handle
  93. // a rolling state between calls.
  94. private static int InternalGetByteCount
  95. (char[] chars, int index, int count, bool flush,
  96. int leftOver, bool allowOptionals)
  97. {
  98. // Validate the parameters.
  99. if (chars == null) {
  100. throw new ArgumentNullException ("chars");
  101. }
  102. if (index < 0 || index > chars.Length) {
  103. throw new ArgumentOutOfRangeException ("index", _("ArgRange_Array"));
  104. }
  105. if (count < 0 || count > (chars.Length - index)) {
  106. throw new ArgumentOutOfRangeException ("count", _("ArgRange_Array"));
  107. }
  108. // Determine the length of the output.
  109. int length = 0;
  110. int leftOverSize = (leftOver >> 8);
  111. byte[] rules = encodingRules;
  112. int ch, rule;
  113. while (count > 0) {
  114. ch = (int)(chars[index++]);
  115. --count;
  116. if (ch < 0x0080) {
  117. rule = rules[ch];
  118. } else {
  119. rule = 0;
  120. }
  121. switch (rule) {
  122. case 0:
  123. // Handle characters that must be fully encoded.
  124. if (leftOverSize == 0) {
  125. ++length;
  126. }
  127. leftOverSize += 16;
  128. while (leftOverSize >= 6) {
  129. ++length;
  130. leftOverSize -= 6;
  131. }
  132. break;
  133. case 1:
  134. // The character is encoded as itself.
  135. if (leftOverSize != 0) {
  136. // Flush the previous encoded sequence.
  137. length += 2;
  138. leftOverSize = 0;
  139. }
  140. ++length;
  141. break;
  142. case 2:
  143. // The character may need to be encoded.
  144. if (allowOptionals) {
  145. goto case 1;
  146. } else {
  147. goto case 0;
  148. }
  149. // Not reached.
  150. case 3:
  151. // Encode the plus sign as "+-".
  152. if (leftOverSize != 0) {
  153. // Flush the previous encoded sequence.
  154. length += 2;
  155. leftOverSize = 0;
  156. }
  157. length += 2;
  158. break;
  159. }
  160. }
  161. if (leftOverSize != 0 && flush) {
  162. length += 2;
  163. }
  164. // Return the length to the caller.
  165. return length;
  166. }
  167. // Get the number of bytes needed to encode a character buffer.
  168. public override int GetByteCount (char[] chars, int index, int count)
  169. {
  170. return InternalGetByteCount (chars, index, count, true, 0, allowOptionals);
  171. }
  172. // Internal version of "GetBytes" that can handle a
  173. // rolling state between calls.
  174. private static int InternalGetBytes
  175. (char[] chars, int charIndex, int charCount,
  176. byte[] bytes, int byteIndex, bool flush,
  177. ref int leftOver, bool allowOptionals)
  178. {
  179. // Validate the parameters.
  180. if (chars == null) {
  181. throw new ArgumentNullException ("chars");
  182. }
  183. if (bytes == null) {
  184. throw new ArgumentNullException ("bytes");
  185. }
  186. if (charIndex < 0 || charIndex > chars.Length) {
  187. throw new ArgumentOutOfRangeException ("charIndex", _("ArgRange_Array"));
  188. }
  189. if (charCount < 0 || charCount > (chars.Length - charIndex)) {
  190. throw new ArgumentOutOfRangeException ("charCount", _("ArgRange_Array"));
  191. }
  192. if (byteIndex < 0 || byteIndex > bytes.Length) {
  193. throw new ArgumentOutOfRangeException ("byteIndex", _("ArgRange_Array"));
  194. }
  195. // Convert the characters.
  196. int posn = byteIndex;
  197. int byteLength = bytes.Length;
  198. int leftOverSize = (leftOver >> 8);
  199. int leftOverBits = (leftOver & 0xFF);
  200. byte[] rules = encodingRules;
  201. String base64 = base64Chars;
  202. int ch, rule;
  203. while (charCount > 0) {
  204. ch = (int)(chars[charIndex++]);
  205. --charCount;
  206. if (ch < 0x0080) {
  207. rule = rules[ch];
  208. } else {
  209. rule = 0;
  210. }
  211. switch (rule) {
  212. case 0:
  213. // Handle characters that must be fully encoded.
  214. if (leftOverSize == 0) {
  215. if (posn >= byteLength) {
  216. throw new ArgumentException (_("Arg_InsufficientSpace"), "bytes");
  217. }
  218. bytes[posn++] = (byte)'+';
  219. }
  220. leftOverBits = ((leftOverBits << 16) | ch);
  221. leftOverSize += 16;
  222. while (leftOverSize >= 6) {
  223. if (posn >= byteLength) {
  224. throw new ArgumentException (_("Arg_InsufficientSpace"), "bytes");
  225. }
  226. leftOverSize -= 6;
  227. bytes[posn++] = (byte)(base64 [leftOverBits >> leftOverSize]);
  228. leftOverBits &= ((1 << leftOverSize) - 1);
  229. }
  230. break;
  231. case 1:
  232. // The character is encoded as itself.
  233. if (leftOverSize != 0) {
  234. // Flush the previous encoded sequence.
  235. if ((posn + 2) > byteLength) {
  236. throw new ArgumentException (_("Arg_InsufficientSpace"), "bytes");
  237. }
  238. bytes[posn++] = (byte)(base64 [leftOverBits << (6 - leftOverSize)]);
  239. bytes[posn++] = (byte)'-';
  240. leftOverSize = 0;
  241. leftOverBits = 0;
  242. }
  243. if (posn >= byteLength) {
  244. throw new ArgumentException (_("Arg_InsufficientSpace"), "bytes");
  245. }
  246. bytes[posn++] = (byte)ch;
  247. break;
  248. case 2:
  249. // The character may need to be encoded.
  250. if (allowOptionals) {
  251. goto case 1;
  252. } else {
  253. goto case 0;
  254. }
  255. // Not reached.
  256. case 3:
  257. // Encode the plus sign as "+-".
  258. if (leftOverSize != 0) {
  259. // Flush the previous encoded sequence.
  260. if ((posn + 2) > byteLength) {
  261. throw new ArgumentException (_("Arg_InsufficientSpace"), "bytes");
  262. }
  263. bytes[posn++] = (byte)(base64 [leftOverBits << (6 - leftOverSize)]);
  264. bytes[posn++] = (byte)'-';
  265. leftOverSize = 0;
  266. leftOverBits = 0;
  267. }
  268. if ((posn + 2) > byteLength) {
  269. throw new ArgumentException (_("Arg_InsufficientSpace"), "bytes");
  270. }
  271. bytes[posn++] = (byte)'+';
  272. bytes[posn++] = (byte)'-';
  273. break;
  274. }
  275. }
  276. if (leftOverSize != 0 && flush) {
  277. if ((posn + 2) > byteLength) {
  278. throw new ArgumentException (_("Arg_InsufficientSpace"), "bytes");
  279. }
  280. bytes[posn++] = (byte)(base64 [leftOverBits << (6 - leftOverSize)]);
  281. bytes[posn++] = (byte)'-';
  282. leftOverSize = 0;
  283. leftOverBits = 0;
  284. }
  285. leftOver = ((leftOverSize << 8) | leftOverBits);
  286. // Return the length to the caller.
  287. return posn - byteIndex;
  288. }
  289. // Get the bytes that result from encoding a character buffer.
  290. public override int GetBytes (char[] chars, int charIndex, int charCount,
  291. byte[] bytes, int byteIndex)
  292. {
  293. int leftOver = 0;
  294. return InternalGetBytes (chars, charIndex, charCount, bytes, byteIndex, true,
  295. ref leftOver, allowOptionals);
  296. }
  297. // Internal version of "GetCharCount" that can handle
  298. // a rolling state between call.s
  299. private static int InternalGetCharCount
  300. (byte[] bytes, int index, int count, int leftOver)
  301. {
  302. // Validate the parameters.
  303. if (bytes == null) {
  304. throw new ArgumentNullException ("bytes");
  305. }
  306. if (index < 0 || index > bytes.Length) {
  307. throw new ArgumentOutOfRangeException ("index", _("ArgRange_Array"));
  308. }
  309. if (count < 0 || count > (bytes.Length - index)) {
  310. throw new ArgumentOutOfRangeException ("count", _("ArgRange_Array"));
  311. }
  312. // Determine the length of the result.
  313. int length = 0;
  314. int byteval, b64value;
  315. bool normal = ((leftOver & 0x01000000) == 0);
  316. bool prevIsPlus = ((leftOver & 0x02000000) != 0);
  317. int leftOverSize = ((leftOver >> 16) & 0xFF);
  318. sbyte[] base64 = base64Values;
  319. while (count > 0) {
  320. byteval = (int)(bytes[index++]);
  321. --count;
  322. if (normal) {
  323. if (byteval != '+') {
  324. // Directly-encoded character.
  325. ++length;
  326. } else {
  327. // Start of a base64-encoded character.
  328. normal = false;
  329. prevIsPlus = true;
  330. }
  331. } else {
  332. // Process the next byte in a base64 sequence.
  333. if (byteval == (int)'-') {
  334. // End of a base64 sequence.
  335. if (prevIsPlus || leftOverSize > 0) {
  336. ++length;
  337. leftOverSize = 0;
  338. }
  339. normal = true;
  340. } else if ((b64value = base64[byteval]) != -1) {
  341. // Extra character in a base64 sequence.
  342. leftOverSize += 6;
  343. if (leftOverSize >= 16) {
  344. ++length;
  345. leftOverSize -= 16;
  346. }
  347. } else {
  348. // Normal character terminating a base64 sequence.
  349. if (leftOverSize > 0) {
  350. ++length;
  351. leftOverSize = 0;
  352. }
  353. ++length;
  354. normal = true;
  355. }
  356. prevIsPlus = false;
  357. }
  358. }
  359. // Return the final length to the caller.
  360. return length;
  361. }
  362. // Get the number of characters needed to decode a byte buffer.
  363. public override int GetCharCount (byte[] bytes, int index, int count)
  364. {
  365. return InternalGetCharCount (bytes, index, count, 0);
  366. }
  367. // Internal version of "GetChars" that can handle a
  368. // rolling state between calls.
  369. private static int InternalGetChars (byte[] bytes, int byteIndex, int byteCount,
  370. char[] chars, int charIndex, ref int leftOver)
  371. {
  372. // Validate the parameters.
  373. if (bytes == null) {
  374. throw new ArgumentNullException ("bytes");
  375. }
  376. if (chars == null) {
  377. throw new ArgumentNullException ("chars");
  378. }
  379. if (byteIndex < 0 || byteIndex > bytes.Length) {
  380. throw new ArgumentOutOfRangeException ("byteIndex", _("ArgRange_Array"));
  381. }
  382. if (byteCount < 0 || byteCount > (bytes.Length - byteIndex)) {
  383. throw new ArgumentOutOfRangeException ("byteCount", _("ArgRange_Array"));
  384. }
  385. if (charIndex < 0 || charIndex > chars.Length) {
  386. throw new ArgumentOutOfRangeException ("charIndex", _("ArgRange_Array"));
  387. }
  388. // Convert the bytes into characters.
  389. int posn = charIndex;
  390. int charLength = chars.Length;
  391. int byteval, b64value;
  392. bool normal = ((leftOver & 0x01000000) == 0);
  393. bool prevIsPlus = ((leftOver & 0x02000000) != 0);
  394. int leftOverSize = ((leftOver >> 16) & 0xFF);
  395. int leftOverBits = (leftOver & 0xFFFF);
  396. sbyte[] base64 = base64Values;
  397. while (byteCount > 0) {
  398. byteval = (int)(bytes[byteIndex++]);
  399. --byteCount;
  400. if (normal) {
  401. if (byteval != '+') {
  402. // Directly-encoded character.
  403. if (posn >= charLength) {
  404. throw new ArgumentException (_("Arg_InsufficientSpace"), "chars");
  405. }
  406. chars[posn++] = (char)byteval;
  407. } else {
  408. // Start of a base64-encoded character.
  409. normal = false;
  410. prevIsPlus = true;
  411. }
  412. } else {
  413. // Process the next byte in a base64 sequence.
  414. if (byteval == (int)'-') {
  415. // End of a base64 sequence.
  416. if (prevIsPlus) {
  417. if (posn >= charLength) {
  418. throw new ArgumentException (_("Arg_InsufficientSpace"), "chars");
  419. }
  420. chars[posn++] = '+';
  421. } else if (leftOverSize > 0) {
  422. if (posn >= charLength) {
  423. throw new ArgumentException (_("Arg_InsufficientSpace"), "chars");
  424. }
  425. chars[posn++] = (char)(leftOverBits << (16 - leftOverSize));
  426. leftOverSize = 0;
  427. leftOverBits = 0;
  428. }
  429. normal = true;
  430. } else if ((b64value = base64[byteval]) != -1) {
  431. // Extra character in a base64 sequence.
  432. leftOverBits = (leftOverBits << 6) | b64value;
  433. leftOverSize += 6;
  434. if (leftOverSize >= 16) {
  435. if (posn >= charLength) {
  436. throw new ArgumentException (_("Arg_InsufficientSpace"), "chars");
  437. }
  438. leftOverSize -= 16;
  439. chars[posn++] = (char)(leftOverBits >> leftOverSize);
  440. leftOverBits &= ((1 << leftOverSize) - 1);
  441. }
  442. } else {
  443. // Normal character terminating a base64 sequence.
  444. if (leftOverSize > 0) {
  445. if (posn >= charLength) {
  446. throw new ArgumentException (_("Arg_InsufficientSpace"), "chars");
  447. }
  448. chars[posn++] = (char)(leftOverBits << (16 - leftOverSize));
  449. leftOverSize = 0;
  450. leftOverBits = 0;
  451. }
  452. if (posn >= charLength) {
  453. throw new ArgumentException (_("Arg_InsufficientSpace"), "chars");
  454. }
  455. chars[posn++] = (char)byteval;
  456. normal = true;
  457. }
  458. prevIsPlus = false;
  459. }
  460. }
  461. leftOver = (leftOverBits | (leftOverSize << 16) |
  462. (normal ? 0 : 0x01000000) |
  463. (prevIsPlus ? 0x02000000 : 0));
  464. // Return the final length to the caller.
  465. return posn - charIndex;
  466. }
  467. // Get the characters that result from decoding a byte buffer.
  468. public override int GetChars (byte[] bytes, int byteIndex, int byteCount,
  469. char[] chars, int charIndex)
  470. {
  471. int leftOver = 0;
  472. return InternalGetChars (bytes, byteIndex, byteCount, chars, charIndex, ref leftOver);
  473. }
  474. // Get the maximum number of bytes needed to encode a
  475. // specified number of characters.
  476. public override int GetMaxByteCount (int charCount)
  477. {
  478. if (charCount < 0) {
  479. throw new ArgumentOutOfRangeException ("charCount", _("ArgRange_NonNegative"));
  480. }
  481. if (charCount == 0)
  482. return 0;
  483. return 8 * (int) (charCount / 3) + (charCount % 3) * 3 + 2;
  484. }
  485. // Get the maximum number of characters needed to decode a
  486. // specified number of bytes.
  487. public override int GetMaxCharCount (int byteCount)
  488. {
  489. if (byteCount < 0) {
  490. throw new ArgumentOutOfRangeException ("byteCount", _("ArgRange_NonNegative"));
  491. }
  492. return byteCount;
  493. }
  494. // Get a UTF7-specific decoder that is attached to this instance.
  495. public override Decoder GetDecoder ()
  496. {
  497. return new UTF7Decoder ();
  498. }
  499. // Get a UTF7-specific encoder that is attached to this instance.
  500. public override Encoder GetEncoder ()
  501. {
  502. return new UTF7Encoder (allowOptionals);
  503. }
  504. // UTF-7 decoder implementation.
  505. private sealed class UTF7Decoder : Decoder
  506. {
  507. // Internal state.
  508. private int leftOver;
  509. // Constructor.
  510. public UTF7Decoder ()
  511. {
  512. leftOver = 0;
  513. }
  514. // Override inherited methods.
  515. public override int GetCharCount (byte[] bytes, int index, int count)
  516. {
  517. return InternalGetCharCount (bytes, index, count, leftOver);
  518. }
  519. public override int GetChars (byte[] bytes, int byteIndex,
  520. int byteCount, char[] chars,
  521. int charIndex)
  522. {
  523. return InternalGetChars (bytes, byteIndex, byteCount, chars, charIndex, ref leftOver);
  524. }
  525. } // class UTF7Decoder
  526. // UTF-7 encoder implementation.
  527. private sealed class UTF7Encoder : Encoder
  528. {
  529. private bool allowOptionals;
  530. private int leftOver;
  531. // Constructor.
  532. public UTF7Encoder (bool allowOptionals)
  533. {
  534. this.allowOptionals = allowOptionals;
  535. this.leftOver = 0;
  536. }
  537. // Override inherited methods.
  538. public override int GetByteCount (char[] chars, int index,
  539. int count, bool flush)
  540. {
  541. return InternalGetByteCount
  542. (chars, index, count, flush, leftOver, allowOptionals);
  543. }
  544. public override int GetBytes (char[] chars, int charIndex,
  545. int charCount, byte[] bytes,
  546. int byteIndex, bool flush)
  547. {
  548. return InternalGetBytes (chars, charIndex, charCount,
  549. bytes, byteIndex, flush,
  550. ref leftOver, allowOptionals);
  551. }
  552. } // class UTF7Encoder
  553. }; // class UTF7Encoding
  554. }; // namespace System.Text