XmlNames_1_0.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. // -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
  2. //
  3. // internal System.Xml.XmlNames
  4. //
  5. // Author:
  6. // Daniel Weber ([email protected])
  7. // Code ported from Open XML 2.3.17
  8. //
  9. // (C) 2001 Daniel Weber
  10. //
  11. using System;
  12. namespace System.Xml
  13. {
  14. /// <summary>
  15. /// Helper class to determine validity of Xml Names
  16. /// </summary>
  17. internal class XmlNames_1_0
  18. {
  19. // Private data members
  20. // public properties
  21. // public methods
  22. // Static methods
  23. /// <summary>
  24. /// Return true if char is a valid Xml character
  25. /// </summary>
  26. /// <param name="S">unicode character to check</param>
  27. /// <returns>true if valid XML character, false otherwise.</returns>
  28. public static bool IsXmlChar(char S)
  29. {
  30. // TODO - verify XmlNames.IsXmlChar(char) ranges correct
  31. if (S == 0x0009) return true;
  32. if (S == 0x000A) return true;
  33. if (S == 0x000D) return true;
  34. if (S == 0x0020) return true;
  35. if ( (S >= 0xE000) & (S <= 0xFFFD) ) return true;
  36. if ( (S >= 0xD800) & (S <=0xDBFF) ) return true;
  37. if ( (S >= 0xDC00) & (S <= 0xDFFF) ) return true;
  38. return false;
  39. }
  40. /// <summary>
  41. /// Returns true if char is a valid Xml whitespace character.
  42. /// S is in unicode.
  43. /// </summary>
  44. /// <param name="S"></param>
  45. /// <returns></returns>
  46. public static bool IsXmlWhiteSpace( char S)
  47. {
  48. // TODO - validate XmlNames.IsXmlWhiteSpace
  49. if (S == 0x0009) return true;
  50. if (S == 0x000A) return true;
  51. if (S == 0x000D) return true;
  52. if (S == 0x0020) return true;
  53. return false;
  54. }
  55. /// <summary>
  56. /// Return true if character is a valid Xml base character
  57. /// </summary>
  58. /// <param name="S">unicode character to check.</param>
  59. /// <returns></returns>
  60. public static bool IsXmlBaseChar(char S)
  61. {
  62. long c = System.Convert.ToInt64(S);
  63. c = c >> 16;
  64. // Taken directly from Appendix B of the XML 1.0 spec
  65. // Do a switch on the high byte to minimize if's on each character.
  66. switch (c)
  67. {
  68. case 0:
  69. if ( (S >= 0x0041) & (S <= 0x005a) ) return true;
  70. if ( (S >= 0x0061) & (S <= 0x007a) ) return true;
  71. if ( (S >= 0x00c0) & (S <= 0x00d6) ) return true;
  72. if ( (S >= 0x00d8) & (S <= 0x00f6) ) return true;
  73. if ( (S >= 0x00f8) & (S <= 0x00ff) ) return true;
  74. break;
  75. case 1:
  76. if ( (S >= 0x0100) & (S <= 0x0131) ) return true;
  77. if ( (S >= 0x0134) & (S <= 0x013E) ) return true;
  78. if ( (S >= 0x0141) & (S <= 0x0148) ) return true;
  79. if ( (S >= 0x014a) & (S <= 0x017e) ) return true;
  80. if ( (S >= 0x0180) & (S <= 0x01c3) ) return true;
  81. if ( (S >= 0x01cd) & (S <= 0x01f0) ) return true;
  82. if ( (S >= 0x01f4) & (S <= 0x01f5) ) return true;
  83. if (S >= 0x01fa) return true;
  84. break;
  85. case 2:
  86. if ( (S >= 0x01fa) & (S <= 0x0217) ) return true;
  87. if ( (S >= 0x0250) & (S <= 0x02a8) ) return true;
  88. if ( (S >= 0x02bb) & (S <= 0x02c1) ) return true;
  89. break;
  90. case 3:
  91. if ( S == 0x0386) return true;
  92. if ( (S >= 0x0388) & (S <= 0x038a) ) return true;
  93. if ( S == 0x038c) return true;
  94. if ( (S >= 0x038e) & (S <= 0x03a1) ) return true;
  95. if ( (S >= 0x03a3) & (S <= 0x03ce) ) return true;
  96. if ( (S >= 0x03D0) & (S <= 0x03D6) ) return true;
  97. if ( S == 0x03DA) return true;
  98. if ( S == 0x03DC) return true;
  99. if ( S == 0x03DE) return true;
  100. if ( S == 0x03E0) return true;
  101. if ( (S >= 0x03E2) & (S <= 0x03F3) ) return true;
  102. break;
  103. case 4:
  104. if ( (S >= 0x0401) & (S <= 0x040C) ) return true;
  105. if ( (S >= 0x040E) & (S <= 0x044F) ) return true;
  106. if ( (S >= 0x0451) & (S <= 0x045C) ) return true;
  107. if ( (S >= 0x045E) & (S <= 0x0481) ) return true;
  108. if ( (S >= 0x0490) & (S <= 0x04C4) ) return true;
  109. if ( (S >= 0x04C7) & (S <= 0x04C8) ) return true;
  110. if ( (S >= 0x04CB) & (S <= 0x04CC) ) return true;
  111. if ( (S >= 0x04D0) & (S <= 0x04EB) ) return true;
  112. if ( (S >= 0x04EE) & (S <= 0x04F5) ) return true;
  113. if ( (S >= 0x04F8) & (S <= 0x04F9) ) return true;
  114. break;
  115. case 5:
  116. if ( (S >= 0x0531) & (S <= 0x0556) ) return true;
  117. if ( S == 0x0559) return true;
  118. if ( (S >= 0x0561) & (S <= 0x0586) ) return true;
  119. if ( (S >= 0x05D0) & (S <= 0x05EA) ) return true;
  120. if ( (S >= 0x05F0) & (S <= 0x05F2) ) return true;
  121. break;
  122. case 6:
  123. if ( (S >= 0x0621) & (S <= 0x063A) ) return true;
  124. if ( (S >= 0x0641) & (S <= 0x064A) ) return true;
  125. if ( (S >= 0x0671) & (S <= 0x06B7) ) return true;
  126. if ( (S >= 0x06BA) & (S <= 0x06BE) ) return true;
  127. if ( (S >= 0x06C0) & (S <= 0x06CE) ) return true;
  128. if ( (S >= 0x06D0) & (S <= 0x06D3) ) return true;
  129. if ( S == 0x06D5) return true;
  130. if ( (S >= 0x06E5) & (S <= 0x06E6) ) return true;
  131. break;
  132. case 9:
  133. if ( (S >= 0x0905) & (S <= 0x0939) ) return true;
  134. if ( S == 0x093D) return true;
  135. if ( (S >= 0x0958) & (S <= 0x0961) ) return true;
  136. if ( (S >= 0x0985) & (S <= 0x098C) ) return true;
  137. if ( (S >= 0x098F) & (S <= 0x0990) ) return true;
  138. if ( (S >= 0x0993) & (S <= 0x09A8) ) return true;
  139. if ( (S >= 0x09AA) & (S <= 0x09B0) ) return true;
  140. if ( S == 0x09B2) return true;
  141. if ( (S >= 0x09B6) & (S <= 0x09B9) ) return true;
  142. if ( (S >= 0x09DC) & (S <= 0x09DD) ) return true;
  143. if ( (S >= 0x09DF) & (S <= 0x09E1) ) return true;
  144. if ( (S >= 0x09F0) & (S <= 0x09F1) ) return true;
  145. break;
  146. case 10: // 0x0Ann
  147. if ( (S >= 0x0A05) & (S <= 0x0A0A) ) return true;
  148. if ( (S >= 0x0A0F) & (S <= 0x0A10) ) return true;
  149. if ( (S >= 0x0A13) & (S <= 0x0A28) ) return true;
  150. if ( (S >= 0x0A2A) & (S <= 0x0A30) ) return true;
  151. if ( (S >= 0x0A32) & (S <= 0x0A33) ) return true;
  152. if ( (S >= 0x0A35) & (S <= 0x0A36) ) return true;
  153. if ( (S >= 0x0A38) & (S <= 0x0A39) ) return true;
  154. if ( (S >= 0x0A59) & (S <= 0x0A5C) ) return true;
  155. if ( S == 0x0A5E) return true;
  156. if ( (S >= 0x0A72) & (S <= 0x0A74) ) return true;
  157. if ( (S >= 0x0A85) & (S <= 0x0A8B) ) return true;
  158. if ( S == 0x0A8D) return true;
  159. if ( (S >= 0x0A8F) & (S <= 0x0A91) ) return true;
  160. if ( (S >= 0x0A93) & (S <= 0x0AA8) ) return true;
  161. if ( (S >= 0x0AAA) & (S <= 0x0AB0) ) return true;
  162. if ( (S >= 0x0AB2) & (S <= 0x0AB3) ) return true;
  163. if ( (S >= 0x0AB5) & (S <= 0x0AB9) ) return true;
  164. if ( S == 0x0ABD) return true;
  165. if ( S == 0x0AE0) return true;
  166. break;
  167. case 11: // 0x0Bnn
  168. if ( (S >= 0x0B05) & (S <= 0x0B0C) ) return true;
  169. if ( (S >= 0x0B0F) & (S <= 0x0B10) ) return true;
  170. if ( (S >= 0x0B13) & (S <= 0x0B28) ) return true;
  171. if ( (S >= 0x0B2A) & (S <= 0x0B30) ) return true;
  172. if ( (S >= 0x0B32) & (S <= 0x0B33) ) return true;
  173. if ( (S >= 0x0B36) & (S <= 0x0B39) ) return true;
  174. if ( S == 0x0B3D) return true;
  175. if ( (S >= 0x0B5C) & (S <= 0x0B5D) ) return true;
  176. if ( (S >= 0x0B5F) & (S <= 0x0B61) ) return true;
  177. if ( (S >= 0x0B85) & (S <= 0x0B8A) ) return true;
  178. if ( (S >= 0x0B8E) & (S <= 0x0B90) ) return true;
  179. if ( (S >= 0x0B92) & (S <= 0x0B95) ) return true;
  180. if ( (S >= 0x0B99) & (S <= 0x0B9A) ) return true;
  181. if ( S == 0x0B9C) return true;
  182. if ( (S >= 0x0B9E) & (S <= 0x0B9F) ) return true;
  183. if ( (S >= 0x0BA3) & (S <= 0x0BA4) ) return true;
  184. if ( (S >= 0x0BA8) & (S <= 0x0BAA) ) return true;
  185. if ( (S >= 0x0BAE) & (S <= 0x0BB5) ) return true;
  186. if ( (S >= 0x0BB7) & (S <= 0x0BB9) ) return true;
  187. break;
  188. case 12: // 0x0Cnn
  189. if ( (S >= 0x0C05) & (S <= 0x0C0C) ) return true;
  190. if ( (S >= 0x0C0E) & (S <= 0x0C10) ) return true;
  191. if ( (S >= 0x0C12) & (S <= 0x0C28) ) return true;
  192. if ( (S >= 0x0C2A) & (S <= 0x0C33) ) return true;
  193. if ( (S >= 0x0C35) & (S <= 0x0C39) ) return true;
  194. if ( (S >= 0x0C60) & (S <= 0x0C61) ) return true;
  195. if ( (S >= 0x0C85) & (S <= 0x0C8C) ) return true;
  196. if ( (S >= 0x0C8E) & (S <= 0x0C90) ) return true;
  197. if ( (S >= 0x0C92) & (S <= 0x0CA8) ) return true;
  198. if ( (S >= 0x0CAA) & (S <= 0x0CB3) ) return true;
  199. if ( (S >= 0x0CB5) & (S <= 0x0CB9) ) return true;
  200. if ( S == 0x0CDE) return true;
  201. if ( (S >= 0x0CE0) & (S <= 0x0CE1) ) return true;
  202. break;
  203. case 13: // 0x0Dnn
  204. if ( (S >= 0x0D05) & (S <= 0x0D0C) ) return true;
  205. if ( (S >= 0x0D0E) & (S <= 0x0D10) ) return true;
  206. if ( (S >= 0x0D12) & (S <= 0x0D28) ) return true;
  207. if ( (S >= 0x0D2A) & (S <= 0x0D39) ) return true;
  208. if ( (S >= 0x0D60) & (S <= 0x0D61) ) return true;
  209. break;
  210. case 14: // 0x0Enn
  211. if ( (S >= 0x0E01) & (S <= 0x0E2E) ) return true;
  212. if ( S == 0x0E30) return true;
  213. if ( (S >= 0x0E32) & (S <= 0x0E33) ) return true;
  214. if ( (S >= 0x0E40) & (S <= 0x0E45) ) return true;
  215. if ( (S >= 0x0E81) & (S <= 0x0E82) ) return true;
  216. if ( S == 0x0E84) return true;
  217. if ( (S >= 0x0E87) & (S <= 0x0E88) ) return true;
  218. if ( S == 0x0E8A) return true;
  219. if ( S == 0x0E8D) return true;
  220. if ( (S >= 0x0E94) & (S <= 0x0E97) ) return true;
  221. if ( (S >= 0x0E99) & (S <= 0x0E9F) ) return true;
  222. if ( (S >= 0x0EA1) & (S <= 0x0EA3) ) return true;
  223. if ( S == 0x0EA5) return true;
  224. if ( S == 0x0EA7) return true;
  225. if ( (S >= 0x0EAA) & (S <= 0x0EAB) ) return true;
  226. if ( (S >= 0x0EAD) & (S <= 0x0EAE) ) return true;
  227. if ( S == 0x0EB0) return true;
  228. if ( (S >= 0x0EB2) & (S <= 0x0EB3) ) return true;
  229. if ( S == 0x0EBD) return true;
  230. if ( (S >= 0x0EC0) & (S <= 0x0EC4) ) return true;
  231. break;
  232. case 0x0F:
  233. if ( (S >= 0x0F40) & (S <= 0x0F47) ) return true;
  234. if ( (S >= 0x0F49) & (S <= 0x0F69) ) return true;
  235. break;
  236. case 0x10:
  237. if ( (S >= 0x10A0) & (S <= 0x10C5) ) return true;
  238. if ( (S >= 0x10D0) & (S <= 0x10F6) ) return true;
  239. break;
  240. case 0x11:
  241. if ( S == 0x1100) return true;
  242. if ( (S >= 0x1102) & (S <= 0x1103) ) return true;
  243. if ( (S >= 0x1105) & (S <= 0x1107) ) return true;
  244. if ( S == 0x1109) return true;
  245. if ( (S >= 0x110B) & (S <= 0x110C) ) return true;
  246. if ( (S >= 0x110E) & (S <= 0x1112) ) return true;
  247. if ( S == 0x113C) return true;
  248. if ( S == 0x113E) return true;
  249. if ( S == 0x1140) return true;
  250. if ( S == 0x114C) return true;
  251. if ( S == 0x114E) return true;
  252. if ( S == 0x1150) return true;
  253. if ( (S >= 0x1154) & (S <= 0x1155) ) return true;
  254. if ( S == 0x1159) return true;
  255. if ( (S >= 0x115F) & (S <= 0x1161) ) return true;
  256. if ( S == 0x1163) return true;
  257. if ( S == 0x1165) return true;
  258. if ( S == 0x1167) return true;
  259. if ( S == 0x1169) return true;
  260. if ( (S >= 0x116D) & (S <= 0x116E) ) return true;
  261. if ( (S >= 0x1172) & (S <= 0x1173) ) return true;
  262. if ( S == 0x1175) return true;
  263. if ( S == 0x119E) return true;
  264. if ( S == 0x11A8) return true;
  265. if ( S == 0x11AB) return true;
  266. if ( (S >= 0x11AE) & (S <= 0x11AF) ) return true;
  267. if ( (S >= 0x11B7) & (S <= 0x11B8) ) return true;
  268. if ( S == 0x11BA) return true;
  269. if ( (S >= 0x11BC) & (S <= 0x11C2) ) return true;
  270. if ( S == 0x11EB) return true;
  271. if ( S == 0x11F0) return true;
  272. if ( S == 0x11F9) return true;
  273. break;
  274. case 0x1E:
  275. if ( (S >= 0x1E00) & (S <= 0x1E9B) ) return true;
  276. if ( (S >= 0x1EA0) & (S <= 0x1EF9) ) return true;
  277. break;
  278. case 0x1F:
  279. if ( (S >= 0x1F00) & (S <= 0x1F15) ) return true;
  280. if ( (S >= 0x1F18) & (S <= 0x1F1D) ) return true;
  281. if ( (S >= 0x1F20) & (S <= 0x1F45) ) return true;
  282. if ( (S >= 0x1F48) & (S <= 0x1F4D) ) return true;
  283. if ( (S >= 0x1F50) & (S <= 0x1F57) ) return true;
  284. if ( S == 0x1F59) return true;
  285. if ( S == 0x1F5B) return true;
  286. if ( S == 0x1F5D) return true;
  287. if ( (S >= 0x1F5F) & (S <= 0x1F7D) ) return true;
  288. if ( (S >= 0x1F80) & (S <= 0x1FB4) ) return true;
  289. if ( (S >= 0x1FB6) & (S <= 0x1FBC) ) return true;
  290. if ( S == 0x1FBE) return true;
  291. if ( (S >= 0x1FC2) & (S <= 0x1FC4) ) return true;
  292. if ( (S >= 0x1FC6) & (S <= 0x1FCC) ) return true;
  293. if ( (S >= 0x1FD0) & (S <= 0x1FD3) ) return true;
  294. if ( (S >= 0x1FD6) & (S <= 0x1FDB) ) return true;
  295. if ( (S >= 0x1FE0) & (S <= 0x1FEC) ) return true;
  296. if ( (S >= 0x1FF2) & (S <= 0x1FF4) ) return true;
  297. if ( (S >= 0x1FF6) & (S <= 0x1FFC) ) return true;
  298. break;
  299. case 33: // 0x21nn
  300. if ( S == 0x2126) return true;
  301. if ( (S >= 0x212A) & (S <= 0x212B) ) return true;
  302. if ( S == 0x212E) return true;
  303. if ( (S >= 0x2180) & (S <= 0x2182) ) return true;
  304. break;
  305. case 48: // 0x30nn
  306. if ( (S >= 0x3041) & (S <= 0x3094) ) return true;
  307. if ( (S >= 0x30A1) & (S <= 0x30FA) ) return true;
  308. break;
  309. case 49: // 0x31nn
  310. if ( (S >= 0x3105) & (S <= 0x312C) ) return true;
  311. break;
  312. default:
  313. if ( (S >= 0xAC00) & (S <= 0xd7a3) ) return true;
  314. break;
  315. }
  316. return false;
  317. }
  318. /// <summary>
  319. /// Return true if S is a valid Xml Ideographic
  320. /// </summary>
  321. /// <param name="S">unicode character to check.</param>
  322. /// <returns></returns>
  323. public static bool IsXmlIdeographic( char S )
  324. {
  325. if ( (S >= 0x4E00) & (S <= 0x9FA5) ) return true;
  326. if ( S == 0x3007) return true;
  327. if ( (S >= 0x3021) & (S <= 0x3029) ) return true;
  328. return false;
  329. }
  330. /// <summary>
  331. /// Return true if S is a valid Xml combining character.
  332. /// </summary>
  333. /// <param name="S">Unicode character to check</param>
  334. /// <returns></returns>
  335. public static bool IsXmlCombiningChar( char S )
  336. {
  337. if ( (S >= 0x0300) & (S <= 0x0345) ) return true;
  338. if ( (S >= 0x0360) & (S <= 0x0361) ) return true;
  339. if ( (S >= 0x0483) & (S <= 0x0486) ) return true;
  340. if ( (S >= 0x0591) & (S <= 0x05A1) ) return true;
  341. if ( (S >= 0x05A3) & (S <= 0x05B9) ) return true;
  342. if ( (S >= 0x05BB) & (S <= 0x05BD) ) return true;
  343. if ( S == 0x05BF) return true;
  344. if ( (S >= 0x05C1) & (S <= 0x05C2) ) return true;
  345. if ( S == 0x05C4) return true;
  346. if ( (S >= 0x064B) & (S <= 0x0652) ) return true;
  347. if ( S == 0x0670) return true;
  348. if ( (S >= 0x06D6) & (S <= 0x06DC) ) return true;
  349. if ( (S >= 0x06DD) & (S <= 0x06DF) ) return true;
  350. if ( (S >= 0x06E0) & (S <= 0x06E4) ) return true;
  351. if ( (S >= 0x06E7) & (S <= 0x06E8) ) return true;
  352. if ( (S >= 0x06EA) & (S <= 0x06ED) ) return true;
  353. if ( (S >= 0x0901) & (S <= 0x0903) ) return true;
  354. if ( S == 0x093C) return true;
  355. if ( (S >= 0x093E) & (S <= 0x094C) ) return true;
  356. if ( S == 0x094D) return true;
  357. if ( (S >= 0x0951) & (S <= 0x0954) ) return true;
  358. if ( (S >= 0x0962) & (S <= 0x0963) ) return true;
  359. if ( (S >= 0x0981) & (S <= 0x0983) ) return true;
  360. if ( S == 0x09BC) return true;
  361. if ( S == 0x09BE) return true;
  362. if ( S == 0x09BF) return true;
  363. if ( (S >= 0x09C0) & (S <= 0x09C4) ) return true;
  364. if ( (S >= 0x09C7) & (S <= 0x09C8) ) return true;
  365. if ( (S >= 0x09CB) & (S <= 0x09CD) ) return true;
  366. if ( S == 0x09D7) return true;
  367. if ( (S >= 0x09E2) & (S <= 0x09E3) ) return true;
  368. if ( S == 0x0A02) return true;
  369. if ( S == 0x0A3C) return true;
  370. if ( S == 0x0A3E) return true;
  371. if ( S == 0x0A3F) return true;
  372. if ( (S >= 0x0A40) & (S <= 0x0A42) ) return true;
  373. if ( (S >= 0x0A47) & (S <= 0x0A48) ) return true;
  374. if ( (S >= 0x0A4B) & (S <= 0x0A4D) ) return true;
  375. if ( (S >= 0x0A70) & (S <= 0x0A71) ) return true;
  376. if ( (S >= 0x0A81) & (S <= 0x0A83) ) return true;
  377. if ( S == 0x0ABC) return true;
  378. if ( (S >= 0x0ABE) & (S <= 0x0AC5) ) return true;
  379. if ( (S >= 0x0AC7) & (S <= 0x0AC9) ) return true;
  380. if ( (S >= 0x0ACB) & (S <= 0x0ACD) ) return true;
  381. if ( (S >= 0x0B01) & (S <= 0x0B03) ) return true;
  382. if ( S == 0x0B3C) return true;
  383. if ( (S >= 0x0B3E) & (S <= 0x0B43) ) return true;
  384. if ( (S >= 0x0B47) & (S <= 0x0B48) ) return true;
  385. if ( (S >= 0x0B4B) & (S <= 0x0B4D) ) return true;
  386. if ( (S >= 0x0B56) & (S <= 0x0B57) ) return true;
  387. if ( (S >= 0x0B82) & (S <= 0x0B83) ) return true;
  388. if ( (S >= 0x0BBE) & (S <= 0x0BC2) ) return true;
  389. if ( (S >= 0x0BC6) & (S <= 0x0BC8) ) return true;
  390. if ( (S >= 0x0BCA) & (S <= 0x0BCD) ) return true;
  391. if ( S == 0x0BD7) return true;
  392. if ( (S >= 0x0C01) & (S <= 0x0C03) ) return true;
  393. if ( (S >= 0x0C3E) & (S <= 0x0C44) ) return true;
  394. if ( (S >= 0x0C46) & (S <= 0x0C48) ) return true;
  395. if ( (S >= 0x0C4A) & (S <= 0x0C4D) ) return true;
  396. if ( (S >= 0x0C55) & (S <= 0x0C56) ) return true;
  397. if ( (S >= 0x0C82) & (S <= 0x0C83) ) return true;
  398. if ( (S >= 0x0CBE) & (S <= 0x0CC4) ) return true;
  399. if ( (S >= 0x0CC6) & (S <= 0x0CC8) ) return true;
  400. if ( (S >= 0x0CCA) & (S <= 0x0CCD) ) return true;
  401. if ( (S >= 0x0CD5) & (S <= 0x0CD6) ) return true;
  402. if ( (S >= 0x0D02) & (S <= 0x0D03) ) return true;
  403. if ( (S >= 0x0D3E) & (S <= 0x0D43) ) return true;
  404. if ( (S >= 0x0D46) & (S <= 0x0D48) ) return true;
  405. if ( (S >= 0x0D4A) & (S <= 0x0D4D) ) return true;
  406. if ( S == 0x0D57) return true;
  407. if ( S == 0x0E31) return true;
  408. if ( (S >= 0x0E34) & (S <= 0x0E3A) ) return true;
  409. if ( (S >= 0x0E47) & (S <= 0x0E4E) ) return true;
  410. if ( S == 0x0EB1) return true;
  411. if ( (S >= 0x0EB4) & (S <= 0x0EB9) ) return true;
  412. if ( (S >= 0x0EBB) & (S <= 0x0EBC) ) return true;
  413. if ( (S >= 0x0EC8) & (S <= 0x0ECD) ) return true;
  414. if ( (S >= 0x0F18) & (S <= 0x0F19) ) return true;
  415. if ( S == 0x0F35) return true;
  416. if ( S == 0x0F37) return true;
  417. if ( S == 0x0F39) return true;
  418. if ( S == 0x0F3E) return true;
  419. if ( S == 0x0F3F) return true;
  420. if ( (S >= 0x0F71) & (S <= 0x0F84) ) return true;
  421. if ( (S >= 0x0F86) & (S <= 0x0F8B) ) return true;
  422. if ( (S >= 0x0F90) & (S <= 0x0F95) ) return true;
  423. if ( S == 0x0F97) return true;
  424. if ( (S >= 0x0F99) & (S <= 0x0FAD) ) return true;
  425. if ( (S >= 0x0FB1) & (S <= 0x0FB7) ) return true;
  426. if ( S == 0x0FB9) return true;
  427. if ( (S >= 0x20D0) & (S <= 0x20DC) ) return true;
  428. if ( S == 0x20E1) return true;
  429. if ( (S >= 0x302A) & (S <= 0x302F) ) return true;
  430. if ( S == 0x3099) return true;
  431. if ( S == 0x309A) return true;
  432. return false;
  433. }
  434. /// <summary>
  435. /// Return true if S is a valid Xml digit.
  436. /// </summary>
  437. /// <param name="S">Unicode character to check.</param>
  438. /// <returns>true if S is a valid unicode digit.</returns>
  439. public static bool IsXmlDigit( char S )
  440. {
  441. // TODO - validiate IsXmlDigit
  442. if ( (S >= 0x0030) & (S <= 0x0039) ) return true;
  443. if ( (S >= 0x0660) & (S <= 0x0669) ) return true;
  444. if ( (S >= 0x06F0) & (S <= 0x06F9) ) return true;
  445. if ( (S >= 0x0966) & (S <= 0x096F) ) return true;
  446. if ( (S >= 0x09E6) & (S <= 0x09EF) ) return true;
  447. if ( (S >= 0x0A66) & (S <= 0x0A6F) ) return true;
  448. if ( (S >= 0x0AE6) & (S <= 0x0AEF) ) return true;
  449. if ( (S >= 0x0B66) & (S <= 0x0B6F) ) return true;
  450. if ( (S >= 0x0BE7) & (S <= 0x0BEF) ) return true;
  451. if ( (S >= 0x0C66) & (S <= 0x0C6F) ) return true;
  452. if ( (S >= 0x0CE6) & (S <= 0x0CEF) ) return true;
  453. if ( (S >= 0x0D66) & (S <= 0x0D6F) ) return true;
  454. if ( (S >= 0x0E50) & (S <= 0x0E59) ) return true;
  455. if ( (S >= 0x0ED0) & (S <= 0x0ED9) ) return true;
  456. if ( (S >= 0x0F20) & (S <= 0x0F29) ) return true;
  457. return false;
  458. }
  459. /// <summary>
  460. /// Return true if S is a valid Xml Extender.
  461. /// </summary>
  462. /// <param name="S">unicode character to check.</param>
  463. /// <returns>true if S is a valid Xml Extender.</returns>
  464. public static bool IsXmlExtender ( char S )
  465. {
  466. if ( S == 0x00B7) return true;
  467. if ( S == 0x02D0) return true;
  468. if ( S == 0x02D1) return true;
  469. if ( S == 0x0387) return true;
  470. if ( S == 0x0640) return true;
  471. if ( S == 0x0E46) return true;
  472. if ( S == 0x0EC6) return true;
  473. if ( S == 0x3005) return true;
  474. if ( (S >= 0x3031) & ( S <= 0x3035) ) return true;
  475. if ( (S >= 0x309D) & ( S <= 0x309E) ) return true;
  476. if ( (S >= 0x30FC) & ( S <= 0x30FE) ) return true;
  477. return false;
  478. }
  479. public static bool IsXmlLetter(char S)
  480. {
  481. return IsXmlIdeographic(S) | IsXmlBaseChar(S);
  482. }
  483. /// <summary>
  484. /// Return true if S is a valid Xml name char.
  485. /// </summary>
  486. /// <param name="S">Unicode character to check</param>
  487. /// <returns>true if S is valid in an xml name.</returns>
  488. public static bool IsXmlNameChar ( char S )
  489. {
  490. if ( IsXmlLetter(S) | IsXmlDigit(S) | IsXmlCombiningChar(S) | IsXmlExtender(S) )
  491. return true;
  492. if ( (S == '.') | (S == '-') | (S == '_') | (S == ':') )
  493. return true;
  494. return false;
  495. }
  496. /// <summary>
  497. /// Return true if the passed string is a valid Xml 1.0 name
  498. /// </summary>
  499. /// <param name="s">String to check for validity</param>
  500. /// <returns>true if string is valid Xml name</returns>
  501. public static bool isXmlName( string s )
  502. {
  503. if ( s.Length == 0 ) return false;
  504. if ( !IsXmlLetter(s[0]) | (s[0] != '_') | (s[0] != ':') )
  505. return false;
  506. for (int i = 1; i < s.Length; i++)
  507. {
  508. if (! IsXmlNameChar( s[i] ) )
  509. return false;
  510. }
  511. return true;
  512. }
  513. // Constructors
  514. }
  515. }