Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2207 lines
70 KiB

  1. /*++
  2. Copyright (c) 1991-1999, Microsoft Corporation All rights reserved.
  3. Module Name:
  4. wctest.c
  5. Abstract:
  6. Test module for NLS API WideCharToMultiByte.
  7. NOTE: This code was simply hacked together quickly in order to
  8. test the different code modules of the NLS component.
  9. This is NOT meant to be a formal regression test.
  10. Revision History:
  11. 06-14-91 JulieB Created.
  12. --*/
  13. //
  14. // Include Files.
  15. //
  16. #include "nlstest.h"
  17. //
  18. // Constant Declarations.
  19. //
  20. #define BUFSIZE 50
  21. #define WC_INVALID_FLAGS ((DWORD)(~(WC_DISCARDNS | WC_SEPCHARS | \
  22. WC_DEFAULTCHAR | WC_COMPOSITECHECK)))
  23. //
  24. // Global Variables.
  25. //
  26. #define mbWCStr "This Is A String."
  27. #define wcWCStr L"This Is A String."
  28. WCHAR wcWCStr2[] = L"This Is A String."; // this could get overwritten
  29. #define mbDefStr "t?t"
  30. #define mbDefStr2 "tXt"
  31. #define wcDefStr L"\x0074\xffef\x0074"
  32. #define wcBestFit L"\x0300"
  33. BYTE mbWCDest[BUFSIZE];
  34. //
  35. // Forward Declarations.
  36. //
  37. int
  38. WC_BadParamCheck();
  39. int
  40. WC_NormalCase();
  41. int
  42. WC_TestFlags();
  43. ////////////////////////////////////////////////////////////////////////////
  44. //
  45. // TestWCToMB
  46. //
  47. // Test routine for WideCharToMultiByte API.
  48. //
  49. // 06-14-91 JulieB Created.
  50. ////////////////////////////////////////////////////////////////////////////
  51. int TestWCToMB()
  52. {
  53. int ErrCount = 0; // error count
  54. //
  55. // Print out what's being done.
  56. //
  57. printf("\n\nTESTING WideCharToMultiByte...\n\n");
  58. //
  59. // Test bad parameters.
  60. //
  61. ErrCount += WC_BadParamCheck();
  62. //
  63. // Test normal cases.
  64. //
  65. ErrCount += WC_NormalCase();
  66. //
  67. // Test flags.
  68. //
  69. ErrCount += WC_TestFlags();
  70. //
  71. // Print out result.
  72. //
  73. printf("\nWideCharToMultiByte: ERRORS = %d\n", ErrCount);
  74. //
  75. // Return total number of errors found.
  76. //
  77. return (ErrCount);
  78. }
  79. ////////////////////////////////////////////////////////////////////////////
  80. //
  81. // WC_BadParamCheck
  82. //
  83. // This routine passes in bad parameters to the API routine and checks to
  84. // be sure they are handled properly. The number of errors encountered
  85. // is returned to the caller.
  86. //
  87. // 06-14-91 JulieB Created.
  88. ////////////////////////////////////////////////////////////////////////////
  89. int WC_BadParamCheck()
  90. {
  91. int NumErrors = 0; // error count - to be returned
  92. int rc; // return code
  93. //
  94. // Null Pointers and Equal Pointers.
  95. //
  96. // Variation 1 - lpWideCharStr = NULL
  97. rc = WideCharToMultiByte( 1252,
  98. 0,
  99. NULL,
  100. -1,
  101. mbWCDest,
  102. BUFSIZE,
  103. NULL,
  104. NULL );
  105. CheckReturnBadParam( rc,
  106. 0,
  107. ERROR_INVALID_PARAMETER,
  108. "lpWideCharStr NULL",
  109. &NumErrors );
  110. // Variation 2 - lpMultiByteStr = NULL
  111. rc = WideCharToMultiByte( 1252,
  112. 0,
  113. wcWCStr,
  114. -1,
  115. NULL,
  116. BUFSIZE,
  117. NULL,
  118. NULL );
  119. CheckReturnBadParam( rc,
  120. 0,
  121. ERROR_INVALID_PARAMETER,
  122. "lpMultiByteStr NULL",
  123. &NumErrors );
  124. // Variation 3 - equal pointers
  125. rc = WideCharToMultiByte( 1252,
  126. 0,
  127. wcWCStr2,
  128. -1,
  129. (LPSTR)wcWCStr2,
  130. (sizeof(wcWCStr2) / sizeof(WCHAR)),
  131. NULL,
  132. NULL );
  133. CheckReturnBadParam( rc,
  134. 0,
  135. ERROR_INVALID_PARAMETER,
  136. "equal pointers",
  137. &NumErrors );
  138. //
  139. // Negative or Zero Lengths.
  140. //
  141. // Variation 1 - cchWideChar = 0
  142. rc = WideCharToMultiByte( 1252,
  143. 0,
  144. wcWCStr,
  145. 0,
  146. mbWCDest,
  147. BUFSIZE,
  148. NULL,
  149. NULL );
  150. CheckReturnBadParam( rc,
  151. 0,
  152. ERROR_INVALID_PARAMETER,
  153. "cchWideChar zero",
  154. &NumErrors );
  155. // Variation 2 - cchMultiByte = negative
  156. rc = WideCharToMultiByte( 1252,
  157. 0,
  158. wcWCStr,
  159. -1,
  160. mbWCDest,
  161. -1,
  162. NULL,
  163. NULL );
  164. CheckReturnBadParam( rc,
  165. 0,
  166. ERROR_INVALID_PARAMETER,
  167. "cchMultiByte negative",
  168. &NumErrors );
  169. //
  170. // Invalid Code Page.
  171. //
  172. // Variation 1 - CodePage = invalid
  173. rc = WideCharToMultiByte( 5,
  174. 0,
  175. wcWCStr,
  176. -1,
  177. mbWCDest,
  178. BUFSIZE,
  179. NULL,
  180. NULL );
  181. CheckReturnBadParam( rc,
  182. 0,
  183. ERROR_INVALID_PARAMETER,
  184. "CodePage Invalid",
  185. &NumErrors );
  186. // Variation 2 - CodePage = invalid
  187. rc = WideCharToMultiByte( 65002,
  188. 0,
  189. wcWCStr,
  190. -1,
  191. mbWCDest,
  192. BUFSIZE,
  193. NULL,
  194. NULL );
  195. CheckReturnBadParam( rc,
  196. 0,
  197. ERROR_INVALID_PARAMETER,
  198. "CodePage Invalid 2",
  199. &NumErrors );
  200. //
  201. // Zero or Invalid Flag Values.
  202. //
  203. // Variation 1 - wFlags = 0
  204. rc = WideCharToMultiByte( 1252,
  205. 0,
  206. wcWCStr,
  207. -1,
  208. mbWCDest,
  209. BUFSIZE,
  210. NULL,
  211. NULL );
  212. CheckReturnValidA( rc,
  213. -1,
  214. mbWCDest,
  215. mbWCStr,
  216. NULL,
  217. "dwFlags zero",
  218. &NumErrors );
  219. // Variation 2 - wFlags = invalid
  220. rc = WideCharToMultiByte( 1252,
  221. WC_INVALID_FLAGS,
  222. wcWCStr,
  223. -1,
  224. mbWCDest,
  225. BUFSIZE,
  226. NULL,
  227. NULL );
  228. CheckReturnBadParam( rc,
  229. 0,
  230. ERROR_INVALID_FLAGS,
  231. "dwFlags invalid",
  232. &NumErrors );
  233. // Variation 3 - wFlags = 0x100
  234. rc = WideCharToMultiByte( 1252,
  235. 0x00000100,
  236. wcWCStr,
  237. -1,
  238. mbWCDest,
  239. BUFSIZE,
  240. NULL,
  241. NULL );
  242. CheckReturnBadParam( rc,
  243. 0,
  244. ERROR_INVALID_FLAGS,
  245. "dwFlags 0x100",
  246. &NumErrors );
  247. //
  248. // Buffer Too Small.
  249. //
  250. // Variation 1 - cchMultiByte = too small
  251. rc = WideCharToMultiByte( 1252,
  252. 0,
  253. wcWCStr,
  254. -1,
  255. mbWCDest,
  256. 2,
  257. NULL,
  258. NULL );
  259. CheckReturnBadParam( rc,
  260. 0,
  261. ERROR_INSUFFICIENT_BUFFER,
  262. "cchMultiByte too small",
  263. &NumErrors );
  264. //
  265. // No Unicode Translation.
  266. //
  267. // Variation 1 - CodePage = CP_SYMBOL
  268. rc = WideCharToMultiByte( CP_SYMBOL,
  269. 0,
  270. L"\xf020\xf033\xf0ca\xf200",
  271. -1,
  272. mbWCDest,
  273. BUFSIZE,
  274. NULL,
  275. NULL );
  276. CheckReturnBadParam( rc,
  277. 0,
  278. ERROR_NO_UNICODE_TRANSLATION,
  279. "CP_SYMBOL - invalid char 0xf200",
  280. &NumErrors );
  281. // Variation 2 - CodePage = CP_SYMBOL
  282. rc = WideCharToMultiByte( CP_SYMBOL,
  283. 0,
  284. L"\xf020\xf033\xf0ca\x0033",
  285. -1,
  286. mbWCDest,
  287. BUFSIZE,
  288. NULL,
  289. NULL );
  290. CheckReturnBadParam( rc,
  291. 0,
  292. ERROR_NO_UNICODE_TRANSLATION,
  293. "CP_SYMBOL - invalid char 0x0033",
  294. &NumErrors );
  295. //
  296. // Return total number of errors found.
  297. //
  298. return (NumErrors);
  299. }
  300. ////////////////////////////////////////////////////////////////////////////
  301. //
  302. // WC_NormalCase
  303. //
  304. // This routine tests the normal cases of the API routine.
  305. //
  306. // 06-14-91 JulieB Created.
  307. ////////////////////////////////////////////////////////////////////////////
  308. int WC_NormalCase()
  309. {
  310. int NumErrors = 0; // error count - to be returned
  311. int rc; // return code
  312. BYTE DefChar = 'X'; // default character
  313. BOOL UsedDef; // if default used
  314. LCID Locale; // save the old locale
  315. #ifdef PERF
  316. DbgBreakPoint();
  317. #endif
  318. //
  319. // cchMultiByte.
  320. //
  321. // Variation 1 - cchMultiByte = length of mbWCDest
  322. rc = WideCharToMultiByte( 1252,
  323. 0,
  324. wcWCStr,
  325. -1,
  326. mbWCDest,
  327. BUFSIZE,
  328. NULL,
  329. NULL );
  330. CheckReturnValidA( rc,
  331. -1,
  332. mbWCDest,
  333. mbWCStr,
  334. NULL,
  335. "cchMultiByte (length)",
  336. &NumErrors );
  337. // Variation 2 - cchMultiByte = 0
  338. mbWCDest[0] = 0;
  339. rc = WideCharToMultiByte( 1252,
  340. 0,
  341. wcWCStr,
  342. -1,
  343. mbWCDest,
  344. 0,
  345. NULL,
  346. NULL );
  347. CheckReturnValidA( rc,
  348. -1,
  349. NULL,
  350. mbWCStr,
  351. NULL,
  352. "cchMultiByte zero",
  353. &NumErrors );
  354. // Variation 3 - cchMultiByte = 0, mbWCDest = NULL
  355. rc = WideCharToMultiByte( 1252,
  356. 0,
  357. wcWCStr,
  358. -1,
  359. NULL,
  360. 0,
  361. NULL,
  362. NULL );
  363. CheckReturnValidA( rc,
  364. -1,
  365. NULL,
  366. mbWCStr,
  367. NULL,
  368. "cchMultiByte zero (NULL ptr)",
  369. &NumErrors );
  370. //
  371. // cchWideChar.
  372. //
  373. // Variation 1 - cchWideChar = length of wcWCStr
  374. rc = WideCharToMultiByte( 1252,
  375. 0,
  376. wcWCStr,
  377. WC_STRING_LEN(wcWCStr),
  378. mbWCDest,
  379. BUFSIZE,
  380. NULL,
  381. NULL );
  382. CheckReturnValidA( rc,
  383. MB_STRING_LEN(mbWCStr),
  384. mbWCDest,
  385. mbWCStr,
  386. NULL,
  387. "cchWideChar (length)",
  388. &NumErrors );
  389. // Variation 2 - cchWideChar = -1
  390. rc = WideCharToMultiByte( 1252,
  391. 0,
  392. wcWCStr,
  393. -1,
  394. mbWCDest,
  395. BUFSIZE,
  396. NULL,
  397. NULL );
  398. CheckReturnValidA( rc,
  399. -1,
  400. mbWCDest,
  401. mbWCStr,
  402. NULL,
  403. "cchWideChar (-1)",
  404. &NumErrors );
  405. // Variation 3 - cchWideChar = length of wcWCStr, no WCDest
  406. rc = WideCharToMultiByte( 1252,
  407. 0,
  408. wcWCStr,
  409. WC_STRING_LEN(wcWCStr),
  410. NULL,
  411. 0,
  412. NULL,
  413. NULL );
  414. CheckReturnValidA( rc,
  415. MB_STRING_LEN(mbWCStr),
  416. NULL,
  417. mbWCStr,
  418. NULL,
  419. "cchWideChar (length), no WCDest",
  420. &NumErrors );
  421. // Variation 4 - cchWideChar = -1, no WCDest
  422. rc = WideCharToMultiByte( 1252,
  423. 0,
  424. wcWCStr,
  425. -1,
  426. NULL,
  427. 0,
  428. NULL,
  429. NULL );
  430. CheckReturnValidA( rc,
  431. -1,
  432. NULL,
  433. mbWCStr,
  434. NULL,
  435. "cchWideChar (-1), no WCDest",
  436. &NumErrors );
  437. //
  438. // CodePage.
  439. //
  440. // Variation 1 - CodePage = CP_ACP
  441. rc = WideCharToMultiByte( CP_ACP,
  442. 0,
  443. wcWCStr,
  444. -1,
  445. mbWCDest,
  446. BUFSIZE,
  447. NULL,
  448. NULL );
  449. CheckReturnValidA( rc,
  450. -1,
  451. mbWCDest,
  452. mbWCStr,
  453. NULL,
  454. "CodePage CP_ACP",
  455. &NumErrors );
  456. // Variation 2 - CodePage = CP_ACP, no WCDest
  457. rc = WideCharToMultiByte( CP_ACP,
  458. 0,
  459. wcWCStr,
  460. -1,
  461. NULL,
  462. 0,
  463. NULL,
  464. NULL );
  465. CheckReturnValidA( rc,
  466. -1,
  467. NULL,
  468. mbWCStr,
  469. NULL,
  470. "CodePage CP_ACP, no WCDest",
  471. &NumErrors );
  472. // Variation 3 - CodePage = CP_OEMCP
  473. rc = WideCharToMultiByte( CP_OEMCP,
  474. 0,
  475. wcWCStr,
  476. -1,
  477. mbWCDest,
  478. BUFSIZE,
  479. NULL,
  480. NULL );
  481. CheckReturnValidA( rc,
  482. -1,
  483. mbWCDest,
  484. mbWCStr,
  485. NULL,
  486. "CodePage CP_OEMCP",
  487. &NumErrors );
  488. // Variation 4 - CodePage = CP_OEMCP, no WCDest
  489. rc = WideCharToMultiByte( CP_OEMCP,
  490. 0,
  491. wcWCStr,
  492. -1,
  493. NULL,
  494. 0,
  495. NULL,
  496. NULL );
  497. CheckReturnValidA( rc,
  498. -1,
  499. NULL,
  500. mbWCStr,
  501. NULL,
  502. "CodePage CP_OEMCP, no WCDest",
  503. &NumErrors );
  504. // Variation 5 - CodePage = 437
  505. rc = WideCharToMultiByte( 437,
  506. 0,
  507. wcWCStr,
  508. -1,
  509. mbWCDest,
  510. BUFSIZE,
  511. NULL,
  512. NULL );
  513. CheckReturnValidA( rc,
  514. -1,
  515. mbWCDest,
  516. mbWCStr,
  517. NULL,
  518. "CodePage 437",
  519. &NumErrors );
  520. // Variation 6 - CodePage = 437, no WCDest
  521. rc = WideCharToMultiByte( 437,
  522. 0,
  523. wcWCStr,
  524. -1,
  525. NULL,
  526. 0,
  527. NULL,
  528. NULL );
  529. CheckReturnValidA( rc,
  530. -1,
  531. NULL,
  532. mbWCStr,
  533. NULL,
  534. "CodePage 437, no WCDest",
  535. &NumErrors );
  536. // Variation 7 - CodePage = 850
  537. rc = WideCharToMultiByte( 850,
  538. 0,
  539. wcWCStr,
  540. -1,
  541. mbWCDest,
  542. BUFSIZE,
  543. NULL,
  544. NULL );
  545. CheckReturnValidA( rc,
  546. -1,
  547. mbWCDest,
  548. mbWCStr,
  549. NULL,
  550. "CodePage 850",
  551. &NumErrors );
  552. // Variation 8 - CodePage = 850, no WCDest
  553. rc = WideCharToMultiByte( 850,
  554. 0,
  555. wcWCStr,
  556. -1,
  557. NULL,
  558. 0,
  559. NULL,
  560. NULL );
  561. CheckReturnValidA( rc,
  562. -1,
  563. NULL,
  564. mbWCStr,
  565. NULL,
  566. "CodePage 850, no WCDest",
  567. &NumErrors );
  568. // Variation 9 - CodePage = 850 best fit
  569. rc = WideCharToMultiByte( 850,
  570. 0,
  571. wcBestFit,
  572. -1,
  573. mbWCDest,
  574. BUFSIZE,
  575. NULL,
  576. NULL );
  577. CheckReturnValidA( rc,
  578. -1,
  579. mbWCDest,
  580. "\x27",
  581. NULL,
  582. "CodePage 850 best fit",
  583. &NumErrors );
  584. // Variation 10 - CodePage = 10000
  585. rc = WideCharToMultiByte( 10000,
  586. 0,
  587. wcWCStr,
  588. -1,
  589. mbWCDest,
  590. BUFSIZE,
  591. NULL,
  592. NULL );
  593. CheckReturnValidA( rc,
  594. -1,
  595. mbWCDest,
  596. mbWCStr,
  597. NULL,
  598. "CodePage 10000",
  599. &NumErrors );
  600. // Variation 11 - CodePage = 10000, no WCDest
  601. rc = WideCharToMultiByte( 10000,
  602. 0,
  603. wcWCStr,
  604. -1,
  605. NULL,
  606. 0,
  607. NULL,
  608. NULL );
  609. CheckReturnValidA( rc,
  610. -1,
  611. NULL,
  612. mbWCStr,
  613. NULL,
  614. "CodePage 10000, no WCDest",
  615. &NumErrors );
  616. // Variation 12 - CodePage = CP_THREAD_ACP
  617. rc = WideCharToMultiByte( CP_THREAD_ACP,
  618. 0,
  619. wcWCStr,
  620. -1,
  621. mbWCDest,
  622. BUFSIZE,
  623. NULL,
  624. NULL );
  625. CheckReturnValidA( rc,
  626. -1,
  627. mbWCDest,
  628. mbWCStr,
  629. NULL,
  630. "CodePage CP_THREAD_ACP",
  631. &NumErrors );
  632. // Variation 13 - CodePage = CP_THREAD_ACP, no WCDest
  633. rc = WideCharToMultiByte( CP_THREAD_ACP,
  634. 0,
  635. wcWCStr,
  636. -1,
  637. NULL,
  638. 0,
  639. NULL,
  640. NULL );
  641. CheckReturnValidA( rc,
  642. -1,
  643. NULL,
  644. mbWCStr,
  645. NULL,
  646. "CodePage CP_THREAD_ACP, no WCDest",
  647. &NumErrors );
  648. // Variation 14 - CodePage = CP_THREAD_ACP
  649. Locale = GetThreadLocale();
  650. SetThreadLocale(0x00000405); // Czech - cp 1250
  651. rc = WideCharToMultiByte( CP_THREAD_ACP,
  652. 0,
  653. L"\x0165\x017a",
  654. -1,
  655. mbWCDest,
  656. BUFSIZE,
  657. NULL,
  658. NULL );
  659. CheckReturnValidA( rc,
  660. -1,
  661. mbWCDest,
  662. "\x9d\x9f",
  663. NULL,
  664. "CodePage CP_THREAD_ACP - Czech cp 1250",
  665. &NumErrors );
  666. SetThreadLocale(Locale); // US - cp 1252
  667. rc = WideCharToMultiByte( CP_THREAD_ACP,
  668. 0,
  669. L"\x0165\x017a",
  670. -1,
  671. mbWCDest,
  672. BUFSIZE,
  673. NULL,
  674. NULL );
  675. CheckReturnValidA( rc,
  676. -1,
  677. mbWCDest,
  678. "\x74\x7a",
  679. NULL,
  680. "CodePage CP_THREAD_ACP - US cp 1252",
  681. &NumErrors );
  682. // Variation 15 - CodePage = CP_SYMBOL
  683. rc = WideCharToMultiByte( CP_SYMBOL,
  684. 0,
  685. L"\xf020\xf033\xf0ca\x0000",
  686. -1,
  687. mbWCDest,
  688. BUFSIZE,
  689. NULL,
  690. NULL );
  691. CheckReturnValidA( rc,
  692. -1,
  693. mbWCDest,
  694. "\x20\x33\xca\x00",
  695. NULL,
  696. "CodePage CP_SYMBOL",
  697. &NumErrors );
  698. // Variation 16 - CodePage = CP_SYMBOL, no WCDest
  699. rc = WideCharToMultiByte( CP_SYMBOL,
  700. 0,
  701. L"\xf020\xf033\xf0ca\x0000",
  702. -1,
  703. NULL,
  704. 0,
  705. NULL,
  706. NULL );
  707. CheckReturnValidA( rc,
  708. -1,
  709. NULL,
  710. "\x20\x33\xca\x00",
  711. NULL,
  712. "CodePage CP_SYMBOL, no WCDest",
  713. &NumErrors );
  714. // Variation 17 - CodePage = CP_SYMBOL
  715. rc = WideCharToMultiByte( CP_SYMBOL,
  716. 0,
  717. L"\xf020\xf033\xf0ca\x0000",
  718. 5,
  719. mbWCDest,
  720. BUFSIZE,
  721. NULL,
  722. NULL );
  723. CheckReturnValidA( rc,
  724. 5,
  725. mbWCDest,
  726. "\x20\x33\xca\x00",
  727. NULL,
  728. "CodePage CP_SYMBOL, size",
  729. &NumErrors );
  730. //
  731. // UTF 7.
  732. //
  733. // Variation 1 - CodePage = CP_UTF7
  734. rc = WideCharToMultiByte( CP_UTF7,
  735. 0,
  736. L"\x5317\x4eac",
  737. -1,
  738. mbWCDest,
  739. BUFSIZE,
  740. NULL,
  741. NULL );
  742. CheckReturnValidA( rc,
  743. -1,
  744. mbWCDest,
  745. "\x2b\x55\x78\x64\x4f\x72\x41\x2d", // +UxdOrA-
  746. NULL,
  747. "CodePage CP_UTF7 - 1",
  748. &NumErrors );
  749. // Variation 2 - CodePage = CP_UTF7
  750. rc = WideCharToMultiByte( CP_UTF7,
  751. 0,
  752. L"\x4e2d\x570b\x66f8\x5e97",
  753. -1,
  754. mbWCDest,
  755. BUFSIZE,
  756. NULL,
  757. NULL );
  758. CheckReturnValidA( rc,
  759. -1, // +Ti1XC2b4Xpc-
  760. mbWCDest,
  761. "\x2b\x54\x69\x31\x58\x43\x32\x62\x34\x58\x70\x63\x2d",
  762. NULL,
  763. "CodePage CP_UTF7 - 2",
  764. &NumErrors );
  765. // Variation 3 - CodePage = CP_UTF7
  766. rc = WideCharToMultiByte( CP_UTF7,
  767. 0,
  768. L"\x003b",
  769. -1,
  770. mbWCDest,
  771. BUFSIZE,
  772. NULL,
  773. NULL );
  774. CheckReturnValidA( rc,
  775. -1,
  776. mbWCDest,
  777. "\x2b\x41\x44\x73\x2d", // +ADs-
  778. NULL,
  779. "CodePage CP_UTF7 - 3",
  780. &NumErrors );
  781. // Variation 4 - CodePage = CP_UTF7
  782. rc = WideCharToMultiByte( CP_UTF7,
  783. 0,
  784. L"\x5eb7\x7199\x5b57\x5178",
  785. -1,
  786. mbWCDest,
  787. BUFSIZE,
  788. NULL,
  789. NULL );
  790. CheckReturnValidA( rc,
  791. -1, // +XrdxmVtXUXg-
  792. mbWCDest,
  793. "\x2b\x58\x72\x64\x78\x6d\x56\x74\x58\x55\x58\x67\x2d",
  794. NULL,
  795. "CodePage CP_UTF7 - 4",
  796. &NumErrors );
  797. // Variation 5 - CodePage = CP_UTF7
  798. rc = WideCharToMultiByte( CP_UTF7,
  799. 0,
  800. L"\x4e95\x4f5c\x6046",
  801. -1,
  802. mbWCDest,
  803. BUFSIZE,
  804. NULL,
  805. NULL );
  806. CheckReturnValidA( rc,
  807. -1, // +TpVPXGBG-
  808. mbWCDest,
  809. "\x2b\x54\x70\x56\x50\x58\x47\x42\x47\x2d",
  810. NULL,
  811. "CodePage CP_UTF7 - 5",
  812. &NumErrors );
  813. // Variation 6 - CodePage = CP_UTF7
  814. rc = WideCharToMultiByte( CP_UTF7,
  815. 0,
  816. L"\x005f",
  817. -1,
  818. mbWCDest,
  819. BUFSIZE,
  820. NULL,
  821. NULL );
  822. CheckReturnValidA( rc,
  823. -1,
  824. mbWCDest,
  825. "\x2b\x41\x46\x38\x2d", // +AF8-
  826. NULL,
  827. "CodePage CP_UTF7 - 6",
  828. &NumErrors );
  829. // Variation 7 - CodePage = CP_UTF7
  830. rc = WideCharToMultiByte( CP_UTF7,
  831. 0,
  832. L"\x0040",
  833. -1,
  834. mbWCDest,
  835. BUFSIZE,
  836. NULL,
  837. NULL );
  838. CheckReturnValidA( rc,
  839. -1,
  840. mbWCDest,
  841. "\x2b\x41\x45\x41\x2d", // +AEA-
  842. NULL,
  843. "CodePage CP_UTF7 - 7",
  844. &NumErrors );
  845. // Variation 8 - CodePage = CP_UTF7
  846. rc = WideCharToMultiByte( CP_UTF7,
  847. 0,
  848. L"\x002b",
  849. -1,
  850. mbWCDest,
  851. BUFSIZE,
  852. NULL,
  853. NULL );
  854. CheckReturnValidA( rc,
  855. -1,
  856. mbWCDest,
  857. "\x2b\x2d", // +-
  858. NULL,
  859. "CodePage CP_UTF7 - 8",
  860. &NumErrors );
  861. // Variation 9 - CodePage = CP_UTF7
  862. rc = WideCharToMultiByte( CP_UTF7,
  863. 0,
  864. L"\x0041\x002b",
  865. -1,
  866. mbWCDest,
  867. BUFSIZE,
  868. NULL,
  869. NULL );
  870. CheckReturnValidA( rc,
  871. -1,
  872. mbWCDest,
  873. "\x41\x2b\x2d", // A+-
  874. NULL,
  875. "CodePage CP_UTF7 - 9",
  876. &NumErrors );
  877. // Variation 10 - CodePage = CP_UTF7
  878. rc = WideCharToMultiByte( CP_UTF7,
  879. 0,
  880. L"\x0040\x002b",
  881. -1,
  882. mbWCDest,
  883. BUFSIZE,
  884. NULL,
  885. NULL );
  886. CheckReturnValidA( rc,
  887. -1,
  888. mbWCDest,
  889. "\x2b\x41\x45\x41\x2d\x2b\x2d", // +AEA-+-
  890. NULL,
  891. "CodePage CP_UTF7 - 10",
  892. &NumErrors );
  893. // Variation 11 - CodePage = CP_UTF7
  894. rc = WideCharToMultiByte( CP_UTF7,
  895. 0,
  896. L"<HTML>",
  897. 6,
  898. mbWCDest,
  899. BUFSIZE,
  900. NULL,
  901. NULL );
  902. CheckReturnValidA( rc,
  903. 14,
  904. mbWCDest,
  905. "+ADw-HTML+AD4-",
  906. NULL,
  907. "CodePage CP_UTF7 - 11",
  908. &NumErrors );
  909. // Variation 12 - CodePage = CP_UTF7
  910. rc = WideCharToMultiByte( CP_UTF7,
  911. 0,
  912. L"<HTML>",
  913. -1,
  914. mbWCDest,
  915. BUFSIZE,
  916. NULL,
  917. NULL );
  918. CheckReturnValidA( rc,
  919. -1,
  920. mbWCDest,
  921. "+ADw-HTML+AD4-",
  922. NULL,
  923. "CodePage CP_UTF7 - 12",
  924. &NumErrors );
  925. //
  926. // UTF 8.
  927. //
  928. // Variation 1 - CodePage = CP_UTF8
  929. rc = WideCharToMultiByte( CP_UTF8,
  930. 0,
  931. L"\x5317\x4eac",
  932. -1,
  933. mbWCDest,
  934. BUFSIZE,
  935. NULL,
  936. NULL );
  937. CheckReturnValidA( rc,
  938. -1,
  939. mbWCDest,
  940. "\xe5\x8c\x97\xe4\xba\xac",
  941. NULL,
  942. "CodePage CP_UTF8 - 1",
  943. &NumErrors );
  944. // Variation 2 - CodePage = CP_UTF8
  945. rc = WideCharToMultiByte( CP_UTF8,
  946. 0,
  947. L"\x4e2d\x570b\x66f8\x5e97",
  948. -1,
  949. mbWCDest,
  950. BUFSIZE,
  951. NULL,
  952. NULL );
  953. CheckReturnValidA( rc,
  954. -1,
  955. mbWCDest,
  956. "\xe4\xb8\xad\xe5\x9c\x8b\xe6\x9b\xb8\xe5\xba\x97",
  957. NULL,
  958. "CodePage CP_UTF8 - 2",
  959. &NumErrors );
  960. // Variation 3 - CodePage = CP_UTF8
  961. rc = WideCharToMultiByte( CP_UTF8,
  962. 0,
  963. L"\x003b",
  964. -1,
  965. mbWCDest,
  966. BUFSIZE,
  967. NULL,
  968. NULL );
  969. CheckReturnValidA( rc,
  970. -1,
  971. mbWCDest,
  972. "\x3b",
  973. NULL,
  974. "CodePage CP_UTF8 - 3",
  975. &NumErrors );
  976. // Variation 4 - CodePage = CP_UTF8
  977. rc = WideCharToMultiByte( CP_UTF8,
  978. 0,
  979. L"\x5eb7\x7199\x5b57\x5178",
  980. -1,
  981. mbWCDest,
  982. BUFSIZE,
  983. NULL,
  984. NULL );
  985. CheckReturnValidA( rc,
  986. -1,
  987. mbWCDest,
  988. "\xe5\xba\xb7\xe7\x86\x99\xe5\xad\x97\xe5\x85\xb8",
  989. NULL,
  990. "CodePage CP_UTF8 - 4",
  991. &NumErrors );
  992. // Variation 5 - CodePage = CP_UTF8
  993. rc = WideCharToMultiByte( CP_UTF8,
  994. 0,
  995. L"\x4e95\x4f5c\x6046",
  996. -1,
  997. mbWCDest,
  998. BUFSIZE,
  999. NULL,
  1000. NULL );
  1001. CheckReturnValidA( rc,
  1002. -1,
  1003. mbWCDest,
  1004. "\xe4\xba\x95\xe4\xbd\x9c\xe6\x81\x86",
  1005. NULL,
  1006. "CodePage CP_UTF8 - 5",
  1007. &NumErrors );
  1008. // Variation 6 - CodePage = CP_UTF8
  1009. rc = WideCharToMultiByte( CP_UTF8,
  1010. 0,
  1011. L"\x005f",
  1012. -1,
  1013. mbWCDest,
  1014. BUFSIZE,
  1015. NULL,
  1016. NULL );
  1017. CheckReturnValidA( rc,
  1018. -1,
  1019. mbWCDest,
  1020. "\x5f",
  1021. NULL,
  1022. "CodePage CP_UTF8 - 6",
  1023. &NumErrors );
  1024. // Variation 7 - CodePage = CP_UTF8
  1025. rc = WideCharToMultiByte( CP_UTF8,
  1026. 0,
  1027. L"\x0040",
  1028. -1,
  1029. mbWCDest,
  1030. BUFSIZE,
  1031. NULL,
  1032. NULL );
  1033. CheckReturnValidA( rc,
  1034. -1,
  1035. mbWCDest,
  1036. "\x40",
  1037. NULL,
  1038. "CodePage CP_UTF8 - 7",
  1039. &NumErrors );
  1040. // Variation 8 - CodePage = CP_UTF8
  1041. rc = WideCharToMultiByte( CP_UTF8,
  1042. 0,
  1043. L"\x002b",
  1044. -1,
  1045. mbWCDest,
  1046. BUFSIZE,
  1047. NULL,
  1048. NULL );
  1049. CheckReturnValidA( rc,
  1050. -1,
  1051. mbWCDest,
  1052. "\x2b",
  1053. NULL,
  1054. "CodePage CP_UTF8 - 8",
  1055. &NumErrors );
  1056. //
  1057. // lpDefaultChar and lpUsedDefaultChar.
  1058. //
  1059. // Variation 1 - default (null, null)
  1060. rc = WideCharToMultiByte( 1252,
  1061. 0,
  1062. wcWCStr,
  1063. -1,
  1064. mbWCDest,
  1065. BUFSIZE,
  1066. NULL,
  1067. NULL );
  1068. CheckReturnValidA( rc,
  1069. -1,
  1070. mbWCDest,
  1071. mbWCStr,
  1072. NULL,
  1073. "default (null, null)",
  1074. &NumErrors );
  1075. // Variation 2 - default (null, non-null)
  1076. rc = WideCharToMultiByte( 1252,
  1077. 0,
  1078. wcDefStr,
  1079. -1,
  1080. mbWCDest,
  1081. BUFSIZE,
  1082. NULL,
  1083. &UsedDef );
  1084. CheckReturnValidA( rc,
  1085. -1,
  1086. mbWCDest,
  1087. mbDefStr,
  1088. &UsedDef,
  1089. "default (null, null)",
  1090. &NumErrors );
  1091. // Variation 3 - default (non-null, null)
  1092. rc = WideCharToMultiByte( 1252,
  1093. 0,
  1094. wcDefStr,
  1095. -1,
  1096. mbWCDest,
  1097. BUFSIZE,
  1098. &DefChar,
  1099. NULL );
  1100. CheckReturnValidA( rc,
  1101. -1,
  1102. mbWCDest,
  1103. mbDefStr2,
  1104. NULL,
  1105. "default (non-null, null)",
  1106. &NumErrors );
  1107. // Variation 4 - default (non-null, non-null)
  1108. rc = WideCharToMultiByte( 1252,
  1109. 0,
  1110. wcDefStr,
  1111. -1,
  1112. mbWCDest,
  1113. BUFSIZE,
  1114. &DefChar,
  1115. &UsedDef );
  1116. CheckReturnValidA( rc,
  1117. -1,
  1118. mbWCDest,
  1119. mbDefStr2,
  1120. &UsedDef,
  1121. "default (non-null, non-null)",
  1122. &NumErrors );
  1123. //
  1124. // WC_NO_BEST_FIT_CHARS flag.
  1125. //
  1126. // Variation 1 - Best Fit
  1127. rc = WideCharToMultiByte( 1252,
  1128. 0,
  1129. L"This \x2566 \xff32 \x2560",
  1130. -1,
  1131. mbWCDest,
  1132. BUFSIZE,
  1133. NULL,
  1134. NULL );
  1135. CheckReturnValidA( rc,
  1136. -1,
  1137. mbWCDest,
  1138. "This \x2d \x52 \xa6",
  1139. NULL,
  1140. "Best Fit",
  1141. &NumErrors );
  1142. // Variation 2 - No Best Fit
  1143. rc = WideCharToMultiByte( 1252,
  1144. WC_NO_BEST_FIT_CHARS,
  1145. L"This \x2566 \xff32 \x2560",
  1146. -1,
  1147. mbWCDest,
  1148. BUFSIZE,
  1149. NULL,
  1150. NULL );
  1151. CheckReturnValidA( rc,
  1152. -1,
  1153. mbWCDest,
  1154. "This ? ? ?",
  1155. NULL,
  1156. "No Best Fit 1",
  1157. &NumErrors );
  1158. // Variation 3 - No Best Fit, no WCDest
  1159. rc = WideCharToMultiByte( 1252,
  1160. WC_NO_BEST_FIT_CHARS,
  1161. L"This \x2566 \xff32 \x2560",
  1162. -1,
  1163. NULL,
  1164. 0,
  1165. NULL,
  1166. NULL );
  1167. CheckReturnValidA( rc,
  1168. -1,
  1169. NULL,
  1170. "This ? ? ?",
  1171. NULL,
  1172. "No Best Fit 1, no WCDest",
  1173. &NumErrors );
  1174. //
  1175. // Return total number of errors found.
  1176. //
  1177. return (NumErrors);
  1178. }
  1179. ////////////////////////////////////////////////////////////////////////////
  1180. //
  1181. // WC_TestFlags
  1182. //
  1183. // This routine tests the different flags of the API routine.
  1184. //
  1185. // 06-14-91 JulieB Created.
  1186. ////////////////////////////////////////////////////////////////////////////
  1187. int WC_TestFlags()
  1188. {
  1189. int NumErrors = 0; // error count - to be returned
  1190. int rc; // return code
  1191. BYTE DefChar = 'X'; // default character
  1192. BOOL UsedDef; // if default used
  1193. //
  1194. // Precomposed.
  1195. //
  1196. // Variation 1 - normal
  1197. rc = WideCharToMultiByte( 1252,
  1198. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1199. L"\x00c0\x00c1",
  1200. -1,
  1201. mbWCDest,
  1202. BUFSIZE,
  1203. NULL,
  1204. NULL );
  1205. CheckReturnValidA( rc,
  1206. -1,
  1207. mbWCDest,
  1208. "\xc0\xc1",
  1209. NULL,
  1210. "precomp (a grave, a acute)",
  1211. &NumErrors );
  1212. // Variation 2 - no WCDest
  1213. rc = WideCharToMultiByte( 1252,
  1214. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1215. L"\x00c0\x00c1",
  1216. -1,
  1217. NULL,
  1218. 0,
  1219. NULL,
  1220. NULL );
  1221. CheckReturnValidA( rc,
  1222. -1,
  1223. NULL,
  1224. "\xc0\xc1",
  1225. NULL,
  1226. "precomp (a grave, a acute), no WCDest",
  1227. &NumErrors );
  1228. //
  1229. // WC_DISCARDNS flag.
  1230. //
  1231. // Variation 1 - normal
  1232. rc = WideCharToMultiByte( 1252,
  1233. WC_COMPOSITECHECK | WC_DISCARDNS,
  1234. wcWCStr,
  1235. -1,
  1236. mbWCDest,
  1237. BUFSIZE,
  1238. &DefChar,
  1239. &UsedDef );
  1240. CheckReturnValidA( rc,
  1241. -1,
  1242. mbWCDest,
  1243. mbWCStr,
  1244. NULL,
  1245. "WC_DISCARDNS",
  1246. &NumErrors );
  1247. // Variation 2 - no WCDest
  1248. rc = WideCharToMultiByte( 1252,
  1249. WC_COMPOSITECHECK | WC_DISCARDNS,
  1250. wcWCStr,
  1251. -1,
  1252. NULL,
  1253. 0,
  1254. &DefChar,
  1255. &UsedDef );
  1256. CheckReturnValidA( rc,
  1257. -1,
  1258. NULL,
  1259. mbWCStr,
  1260. NULL,
  1261. "WC_DISCARDNS, no WCDest",
  1262. &NumErrors );
  1263. // Variation 3 - acute
  1264. rc = WideCharToMultiByte( 1252,
  1265. WC_COMPOSITECHECK | WC_DISCARDNS,
  1266. L"\x0045\x0301\x0045\x0301",
  1267. -1,
  1268. mbWCDest,
  1269. BUFSIZE,
  1270. NULL,
  1271. NULL );
  1272. CheckReturnValidA( rc,
  1273. -1,
  1274. mbWCDest,
  1275. "\xc9\xc9",
  1276. NULL,
  1277. "WC_DISCARDNS acute",
  1278. &NumErrors );
  1279. // Variation 4 - acute, default
  1280. rc = WideCharToMultiByte( 1252,
  1281. WC_COMPOSITECHECK | WC_DISCARDNS,
  1282. L"\x0045\x0301\x0045\x0301",
  1283. -1,
  1284. mbWCDest,
  1285. BUFSIZE,
  1286. &DefChar,
  1287. &UsedDef );
  1288. CheckReturnValidA( rc,
  1289. -1,
  1290. mbWCDest,
  1291. "\xc9\xc9",
  1292. NULL,
  1293. "WC_DISCARDNS acute, default",
  1294. &NumErrors );
  1295. // Variation 5 - no precomp form
  1296. rc = WideCharToMultiByte( 932,
  1297. WC_COMPOSITECHECK | WC_DISCARDNS,
  1298. L"\x3093\x309b",
  1299. -1,
  1300. mbWCDest,
  1301. BUFSIZE,
  1302. &DefChar,
  1303. &UsedDef );
  1304. CheckReturnValidA( rc,
  1305. -1,
  1306. mbWCDest,
  1307. "\x82\xf1",
  1308. NULL,
  1309. "WC_DISCARDNS, no precomp",
  1310. &NumErrors );
  1311. // Variation 6 - no precomp form, no WCDest
  1312. rc = WideCharToMultiByte( 932,
  1313. WC_COMPOSITECHECK | WC_DISCARDNS,
  1314. L"\x3093\x309b",
  1315. -1,
  1316. NULL,
  1317. 0,
  1318. &DefChar,
  1319. &UsedDef );
  1320. CheckReturnValidA( rc,
  1321. -1,
  1322. NULL,
  1323. "\x82\xf1",
  1324. NULL,
  1325. "WC_DISCARDNS, no precomp, no WCDest",
  1326. &NumErrors );
  1327. //
  1328. // WC_SEPCHARS flag.
  1329. //
  1330. // Variation 1 - normal
  1331. rc = WideCharToMultiByte( 1252,
  1332. WC_COMPOSITECHECK | WC_SEPCHARS,
  1333. wcWCStr,
  1334. -1,
  1335. mbWCDest,
  1336. BUFSIZE,
  1337. &DefChar,
  1338. &UsedDef );
  1339. CheckReturnValidA( rc,
  1340. -1,
  1341. mbWCDest,
  1342. mbWCStr,
  1343. NULL,
  1344. "WC_SEPCHARS",
  1345. &NumErrors );
  1346. // Variation 2 - no WCDest
  1347. rc = WideCharToMultiByte( 1252,
  1348. WC_COMPOSITECHECK | WC_SEPCHARS,
  1349. wcWCStr,
  1350. -1,
  1351. NULL,
  1352. 0,
  1353. &DefChar,
  1354. &UsedDef );
  1355. CheckReturnValidA( rc,
  1356. -1,
  1357. NULL,
  1358. mbWCStr,
  1359. NULL,
  1360. "WC_SEPCHARS, no WCDest",
  1361. &NumErrors );
  1362. // Variation 3 - no precomp form
  1363. rc = WideCharToMultiByte( 932,
  1364. WC_COMPOSITECHECK | WC_SEPCHARS,
  1365. L"\x3093\x309b",
  1366. -1,
  1367. mbWCDest,
  1368. BUFSIZE,
  1369. &DefChar,
  1370. &UsedDef );
  1371. CheckReturnValidA( rc,
  1372. -1,
  1373. mbWCDest,
  1374. "\x82\xf1\x81\x4a",
  1375. NULL,
  1376. "WC_SEPCHARS, no precomp",
  1377. &NumErrors );
  1378. // Variation 4 - no precomp form, no WCDest
  1379. rc = WideCharToMultiByte( 932,
  1380. WC_COMPOSITECHECK | WC_SEPCHARS,
  1381. L"\x3093\x309b",
  1382. -1,
  1383. NULL,
  1384. 0,
  1385. &DefChar,
  1386. &UsedDef );
  1387. CheckReturnValidA( rc,
  1388. -1,
  1389. NULL,
  1390. "\x82\xf1\x81\x4a",
  1391. NULL,
  1392. "WC_SEPCHARS, no precomp, no WCDest",
  1393. &NumErrors );
  1394. //
  1395. // WC_DEFAULTCHAR flag.
  1396. //
  1397. // Variation 1 - normal
  1398. rc = WideCharToMultiByte( 1252,
  1399. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1400. wcWCStr,
  1401. -1,
  1402. mbWCDest,
  1403. BUFSIZE,
  1404. &DefChar,
  1405. &UsedDef );
  1406. CheckReturnValidA( rc,
  1407. -1,
  1408. mbWCDest,
  1409. mbWCStr,
  1410. NULL,
  1411. "WC_DEFAULTCHAR",
  1412. &NumErrors );
  1413. // Variation 2 - no WCDest
  1414. rc = WideCharToMultiByte( 1252,
  1415. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1416. wcWCStr,
  1417. -1,
  1418. NULL,
  1419. 0,
  1420. &DefChar,
  1421. &UsedDef );
  1422. CheckReturnValidA( rc,
  1423. -1,
  1424. NULL,
  1425. mbWCStr,
  1426. NULL,
  1427. "WC_DEFAULTCHAR, no WCDest",
  1428. &NumErrors );
  1429. // Variation 3 - no precomp form
  1430. rc = WideCharToMultiByte( 932,
  1431. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1432. L"\x3093\x309b",
  1433. -1,
  1434. mbWCDest,
  1435. BUFSIZE,
  1436. &DefChar,
  1437. &UsedDef );
  1438. CheckReturnValidA( rc,
  1439. -1,
  1440. mbWCDest,
  1441. "X",
  1442. NULL,
  1443. "WC_DEFAULTCHAR, no precomp",
  1444. &NumErrors );
  1445. // Variation 4 - no precomp form, no WCDest
  1446. rc = WideCharToMultiByte( 932,
  1447. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1448. L"\x3093\x309b",
  1449. -1,
  1450. NULL,
  1451. 0,
  1452. &DefChar,
  1453. &UsedDef );
  1454. CheckReturnValidA( rc,
  1455. -1,
  1456. NULL,
  1457. "X",
  1458. NULL,
  1459. "WC_DEFAULTCHAR, no precomp, no WCDest",
  1460. &NumErrors );
  1461. // Variation 5 - no precomp form, extra nonspace
  1462. rc = WideCharToMultiByte( 932,
  1463. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1464. L"\x3093\x309b\x309b",
  1465. -1,
  1466. mbWCDest,
  1467. BUFSIZE,
  1468. &DefChar,
  1469. &UsedDef );
  1470. CheckReturnValidA( rc,
  1471. -1,
  1472. mbWCDest,
  1473. "X",
  1474. NULL,
  1475. "WC_DEFAULTCHAR, no precomp extra nonspace",
  1476. &NumErrors );
  1477. // Variation 6 - no precomp form, extra nonspace, no WCDest
  1478. rc = WideCharToMultiByte( 932,
  1479. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1480. L"\x3093\x309b\x309b",
  1481. -1,
  1482. NULL,
  1483. 0,
  1484. &DefChar,
  1485. &UsedDef );
  1486. CheckReturnValidA( rc,
  1487. -1,
  1488. NULL,
  1489. "X",
  1490. NULL,
  1491. "WC_DEFAULTCHAR, no precomp extra nonspace, no WCDest",
  1492. &NumErrors );
  1493. // Variation 7 - no precomp form, no default
  1494. rc = WideCharToMultiByte( 932,
  1495. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1496. L"\x3093\x309b\x309b",
  1497. -1,
  1498. mbWCDest,
  1499. BUFSIZE,
  1500. NULL,
  1501. NULL );
  1502. CheckReturnValidA( rc,
  1503. -1,
  1504. mbWCDest,
  1505. "\x3f",
  1506. NULL,
  1507. "WC_DEFAULTCHAR, no precomp no default",
  1508. &NumErrors );
  1509. // Variation 8 - no precomp form, no WCDest, no default
  1510. rc = WideCharToMultiByte( 932,
  1511. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1512. L"\x3093\x309b\x309b",
  1513. -1,
  1514. NULL,
  1515. 0,
  1516. NULL,
  1517. NULL );
  1518. CheckReturnValidA( rc,
  1519. -1,
  1520. NULL,
  1521. "\x3f",
  1522. NULL,
  1523. "WC_DEFAULTCHAR, no precomp no default, no WCDest",
  1524. &NumErrors );
  1525. // Variation 9 - no precomp form, extra nonspace
  1526. rc = WideCharToMultiByte( 1252,
  1527. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1528. L"\x0065\x0303\x0303",
  1529. -1,
  1530. mbWCDest,
  1531. BUFSIZE,
  1532. &DefChar,
  1533. &UsedDef );
  1534. CheckReturnValidA( rc,
  1535. -1,
  1536. mbWCDest,
  1537. "X",
  1538. NULL,
  1539. "WC_DEFAULTCHAR, no precomp 2, extra nonspace",
  1540. &NumErrors );
  1541. // Variation 10 - no precomp form, extra nonspace, no WCDest
  1542. rc = WideCharToMultiByte( 1252,
  1543. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1544. L"\x0065\x0303\x0303",
  1545. -1,
  1546. NULL,
  1547. 0,
  1548. &DefChar,
  1549. &UsedDef );
  1550. CheckReturnValidA( rc,
  1551. -1,
  1552. NULL,
  1553. "X",
  1554. NULL,
  1555. "WC_DEFAULTCHAR, no precomp 2, extra nonspace, no WCDest",
  1556. &NumErrors );
  1557. //
  1558. // Circumflex check.
  1559. //
  1560. // Variation 1 - circumflex (no flag)
  1561. rc = WideCharToMultiByte( 437,
  1562. 0,
  1563. L"\x0045\x0302",
  1564. -1,
  1565. mbWCDest,
  1566. BUFSIZE,
  1567. NULL,
  1568. NULL );
  1569. CheckReturnValidA( rc,
  1570. -1,
  1571. mbWCDest,
  1572. "\x45\x5e",
  1573. NULL,
  1574. "circumflex (no flag)",
  1575. &NumErrors );
  1576. // Variation 2 - circumflex
  1577. rc = WideCharToMultiByte( 437,
  1578. WC_COMPOSITECHECK | WC_SEPCHARS,
  1579. L"\x0045\x0302",
  1580. -1,
  1581. mbWCDest,
  1582. BUFSIZE,
  1583. NULL,
  1584. NULL );
  1585. CheckReturnValidA( rc,
  1586. -1,
  1587. mbWCDest,
  1588. "E",
  1589. NULL,
  1590. "circumflex",
  1591. &NumErrors );
  1592. // Variation 3 - circumflex, no WCDest
  1593. rc = WideCharToMultiByte( 437,
  1594. WC_COMPOSITECHECK | WC_SEPCHARS,
  1595. L"\x0045\x0302",
  1596. -1,
  1597. NULL,
  1598. 0,
  1599. NULL,
  1600. NULL );
  1601. CheckReturnValidA( rc,
  1602. -1,
  1603. NULL,
  1604. "\x88",
  1605. NULL,
  1606. "circumflex, no WCDest",
  1607. &NumErrors );
  1608. //
  1609. // Half Ring Below check.
  1610. //
  1611. // Variation 1 - half ring below
  1612. rc = WideCharToMultiByte( 437,
  1613. WC_COMPOSITECHECK | WC_DISCARDNS,
  1614. L"\x0045\x031c",
  1615. -1,
  1616. mbWCDest,
  1617. BUFSIZE,
  1618. NULL,
  1619. NULL );
  1620. CheckReturnValidA( rc,
  1621. -1,
  1622. mbWCDest,
  1623. "\x45",
  1624. NULL,
  1625. "half ring below",
  1626. &NumErrors );
  1627. // Variation 2 - half ring below, no WCDest
  1628. rc = WideCharToMultiByte( 437,
  1629. WC_COMPOSITECHECK | WC_DISCARDNS,
  1630. L"\x0045\x031c",
  1631. -1,
  1632. NULL,
  1633. 0,
  1634. NULL,
  1635. NULL );
  1636. CheckReturnValidA( rc,
  1637. -1,
  1638. NULL,
  1639. "\x45",
  1640. NULL,
  1641. "half ring below, no WCDest",
  1642. &NumErrors );
  1643. //
  1644. // TILDE check.
  1645. //
  1646. // Variation 1 - tilde, discardns
  1647. rc = WideCharToMultiByte( 437,
  1648. WC_COMPOSITECHECK | WC_DISCARDNS,
  1649. L"\x0042\x0303",
  1650. -1,
  1651. mbWCDest,
  1652. BUFSIZE,
  1653. NULL,
  1654. NULL );
  1655. CheckReturnValidA( rc,
  1656. -1,
  1657. mbWCDest,
  1658. "\x42",
  1659. NULL,
  1660. "tilde, discardns",
  1661. &NumErrors );
  1662. // Variation 2 - tilde, discardns, no WCDest
  1663. rc = WideCharToMultiByte( 437,
  1664. WC_COMPOSITECHECK | WC_DISCARDNS,
  1665. L"\x0042\x0303",
  1666. -1,
  1667. NULL,
  1668. 0,
  1669. NULL,
  1670. NULL );
  1671. CheckReturnValidA( rc,
  1672. -1,
  1673. NULL,
  1674. "\x42",
  1675. NULL,
  1676. "tilde, discardns, no WCDest",
  1677. &NumErrors );
  1678. // Variation 3 - tilde, sepchars
  1679. rc = WideCharToMultiByte( 437,
  1680. WC_COMPOSITECHECK | WC_SEPCHARS,
  1681. L"\x0042\x0303",
  1682. -1,
  1683. mbWCDest,
  1684. BUFSIZE,
  1685. NULL,
  1686. NULL );
  1687. CheckReturnValidA( rc,
  1688. -1,
  1689. mbWCDest,
  1690. "\x42\x7e",
  1691. NULL,
  1692. "tilde, sepchars",
  1693. &NumErrors );
  1694. // Variation 4 - tilde, sepchars, no WCDest
  1695. rc = WideCharToMultiByte( 437,
  1696. WC_COMPOSITECHECK | WC_SEPCHARS,
  1697. L"\x0042\x0303",
  1698. -1,
  1699. NULL,
  1700. 0,
  1701. NULL,
  1702. NULL );
  1703. CheckReturnValidA( rc,
  1704. -1,
  1705. NULL,
  1706. "\x42\x7e",
  1707. NULL,
  1708. "tilde, sepchars, no WCDest",
  1709. &NumErrors );
  1710. // Variation 5 - tilde, defaultchar
  1711. rc = WideCharToMultiByte( 437,
  1712. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1713. L"\x0042\x0303",
  1714. -1,
  1715. mbWCDest,
  1716. BUFSIZE,
  1717. NULL,
  1718. NULL );
  1719. CheckReturnValidA( rc,
  1720. -1,
  1721. mbWCDest,
  1722. "\x3f",
  1723. NULL,
  1724. "tilde, defaultchar",
  1725. &NumErrors );
  1726. // Variation 6 - tilde, defaultchar, no WCDest
  1727. rc = WideCharToMultiByte( 437,
  1728. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1729. L"\x0042\x0303",
  1730. -1,
  1731. NULL,
  1732. 0,
  1733. NULL,
  1734. NULL );
  1735. CheckReturnValidA( rc,
  1736. -1,
  1737. NULL,
  1738. "\x3f",
  1739. NULL,
  1740. "tilde, defaultchar, no WCDest",
  1741. &NumErrors );
  1742. //
  1743. // CP 437 - Nonspace character first in string.
  1744. //
  1745. // Variation 1 - first char, discardns
  1746. rc = WideCharToMultiByte( 437,
  1747. WC_COMPOSITECHECK | WC_DISCARDNS,
  1748. L"\x0301\x0045",
  1749. -1,
  1750. mbWCDest,
  1751. BUFSIZE,
  1752. NULL,
  1753. NULL );
  1754. CheckReturnValidA( rc,
  1755. -1,
  1756. mbWCDest,
  1757. "\x45",
  1758. NULL,
  1759. "first char, discardns",
  1760. &NumErrors );
  1761. // Variation 2 - first char, sepchars
  1762. rc = WideCharToMultiByte( 437,
  1763. WC_COMPOSITECHECK | WC_SEPCHARS,
  1764. L"\x0301\x0045",
  1765. -1,
  1766. mbWCDest,
  1767. BUFSIZE,
  1768. NULL,
  1769. NULL );
  1770. CheckReturnValidA( rc,
  1771. -1,
  1772. mbWCDest,
  1773. "\x27\x45",
  1774. NULL,
  1775. "first char, sepchars",
  1776. &NumErrors );
  1777. // Variation 3 - first char, defaultchar
  1778. rc = WideCharToMultiByte( 437,
  1779. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1780. L"\x0301\x0045",
  1781. -1,
  1782. mbWCDest,
  1783. BUFSIZE,
  1784. NULL,
  1785. NULL );
  1786. CheckReturnValidA( rc,
  1787. -1,
  1788. mbWCDest,
  1789. "\x3f\x45",
  1790. NULL,
  1791. "first char, defaultchar",
  1792. &NumErrors );
  1793. //
  1794. // CP 437 - Composite Check Flags.
  1795. //
  1796. // Variation 1 - composite check - no flags
  1797. rc = WideCharToMultiByte( 437,
  1798. 0,
  1799. L"\x0045\x0302\x0045\x0308\x0045\x0305",
  1800. -1,
  1801. mbWCDest,
  1802. BUFSIZE,
  1803. NULL,
  1804. NULL );
  1805. CheckReturnValidA( rc,
  1806. -1,
  1807. mbWCDest,
  1808. "\x45\x5e\x45\x22\x45\x3f",
  1809. NULL,
  1810. "437 composite check",
  1811. &NumErrors );
  1812. // Variation 2 - composite check - discardns
  1813. rc = WideCharToMultiByte( 437,
  1814. WC_COMPOSITECHECK | WC_DISCARDNS,
  1815. L"\x0045\x0302\x0045\x0308\x0045\x0305",
  1816. -1,
  1817. mbWCDest,
  1818. BUFSIZE,
  1819. NULL,
  1820. NULL );
  1821. CheckReturnValidA( rc,
  1822. -1,
  1823. mbWCDest,
  1824. "EEE",
  1825. NULL,
  1826. "437 composite check - discardns",
  1827. &NumErrors );
  1828. // Variation 3 - composite check - sepchars
  1829. rc = WideCharToMultiByte( 437,
  1830. WC_COMPOSITECHECK | WC_SEPCHARS,
  1831. L"\x0045\x0302\x0045\x0308\x0045\x0305",
  1832. -1,
  1833. mbWCDest,
  1834. BUFSIZE,
  1835. NULL,
  1836. NULL );
  1837. CheckReturnValidA( rc,
  1838. -1,
  1839. mbWCDest,
  1840. "EEE?",
  1841. NULL,
  1842. "437 composite check - sepchars",
  1843. &NumErrors );
  1844. // Variation 4 - composite check - defaultchar
  1845. rc = WideCharToMultiByte( 437,
  1846. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1847. L"\x0045\x0302\x0045\x0308\x0045\x0305",
  1848. -1,
  1849. mbWCDest,
  1850. BUFSIZE,
  1851. NULL,
  1852. NULL );
  1853. CheckReturnValidA( rc,
  1854. -1,
  1855. mbWCDest,
  1856. "EE?",
  1857. NULL,
  1858. "437 composite check - defaultchar",
  1859. &NumErrors );
  1860. //
  1861. // CP 437 - Double Nonspacing Chars Check.
  1862. //
  1863. // Variation 1 - double nonspace check - no flags
  1864. rc = WideCharToMultiByte( 437,
  1865. 0,
  1866. L"\x0045\x0302\x0045\x0302\x0302",
  1867. -1,
  1868. mbWCDest,
  1869. BUFSIZE,
  1870. NULL,
  1871. NULL );
  1872. CheckReturnValidA( rc,
  1873. -1,
  1874. mbWCDest,
  1875. "\x45\x5e\x45\x5e\x5e",
  1876. NULL,
  1877. "437 double nonspace check",
  1878. &NumErrors );
  1879. // Variation 2 - double nonspace check - discardns
  1880. rc = WideCharToMultiByte( 437,
  1881. WC_COMPOSITECHECK | WC_DISCARDNS,
  1882. L"\x0045\x0302\x0045\x0302\x0302",
  1883. -1,
  1884. mbWCDest,
  1885. BUFSIZE,
  1886. NULL,
  1887. NULL );
  1888. CheckReturnValidA( rc,
  1889. -1,
  1890. mbWCDest,
  1891. "EE",
  1892. NULL,
  1893. "437 double nonspace check - discardns",
  1894. &NumErrors );
  1895. // Variation 3 - double nonspace check - sepchars
  1896. rc = WideCharToMultiByte( 437,
  1897. WC_COMPOSITECHECK | WC_SEPCHARS,
  1898. L"\x0045\x0302\x0045\x0302\x0302",
  1899. -1,
  1900. mbWCDest,
  1901. BUFSIZE,
  1902. NULL,
  1903. NULL );
  1904. CheckReturnValidA( rc,
  1905. -1,
  1906. mbWCDest,
  1907. "EE^",
  1908. NULL,
  1909. "437 double nonspace check - sepchars",
  1910. &NumErrors );
  1911. // Variation 4 - double nonspace check - defaultchar
  1912. rc = WideCharToMultiByte( 437,
  1913. WC_COMPOSITECHECK | WC_DEFAULTCHAR,
  1914. L"\x0045\x0302\x0045\x0302\x0302",
  1915. -1,
  1916. mbWCDest,
  1917. BUFSIZE,
  1918. NULL,
  1919. NULL );
  1920. CheckReturnValidA( rc,
  1921. -1,
  1922. mbWCDest,
  1923. "E?",
  1924. NULL,
  1925. "437 double nonspace check - defaultchar",
  1926. &NumErrors );
  1927. //
  1928. // CP 936.
  1929. //
  1930. // Variation 1 - ideographic comma
  1931. rc = WideCharToMultiByte( 936,
  1932. WC_COMPOSITECHECK | WC_SEPCHARS,
  1933. L"\x3001",
  1934. -1,
  1935. mbWCDest,
  1936. BUFSIZE,
  1937. NULL,
  1938. NULL );
  1939. CheckReturnValidA( rc,
  1940. -1,
  1941. mbWCDest,
  1942. "\xa1\xa2",
  1943. NULL,
  1944. "cp 936",
  1945. &NumErrors );
  1946. // Variation 2 - ideographic comma, no WCDest
  1947. rc = WideCharToMultiByte( 936,
  1948. WC_COMPOSITECHECK | WC_SEPCHARS,
  1949. L"\x3001",
  1950. -1,
  1951. NULL,
  1952. 0,
  1953. NULL,
  1954. NULL );
  1955. CheckReturnValidA( rc,
  1956. -1,
  1957. NULL,
  1958. "\xa1\xa2",
  1959. NULL,
  1960. "cp 936, no WCDest",
  1961. &NumErrors );
  1962. //
  1963. // Return total number of errors found.
  1964. //
  1965. return (NumErrors);
  1966. }