tdfont.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. package door
  2. import (
  3. "bytes"
  4. "fmt"
  5. "strconv"
  6. "strings"
  7. )
  8. type BlockFont struct {
  9. Characters []int
  10. Data [][][]byte
  11. }
  12. /*
  13. func BytesHexed(output []byte) {
  14. fmt.Printf("BH: ")
  15. for _, ch := range output {
  16. fmt.Printf("%02x ", ch)
  17. }
  18. fmt.Println("")
  19. }
  20. func BytesArrayHexed(output *[][]byte) {
  21. for _, out := range *output {
  22. BytesHexed(out)
  23. }
  24. }
  25. */
  26. // Make []strings all the same length
  27. func normalizeBlock(block *[][]byte) {
  28. var max int
  29. // StringO(block)
  30. for _, line := range *block {
  31. l := len(line)
  32. if max < l {
  33. max = l
  34. }
  35. }
  36. // fmt.Printf("max = %d\n", max)
  37. for idx := range *block {
  38. // l := len(line)
  39. for len((*block)[idx]) < max {
  40. //(*block)[idx] += byte(0x20) //append((*block)[idx], byte{0x20})
  41. (*block)[idx] = append((*block)[idx], byte(0x20))
  42. }
  43. }
  44. // StringO(block)
  45. // fmt.Println("== normalized ==")
  46. }
  47. // Get Character information from BlockFont return Normalize
  48. func (bf *BlockFont) GetCharacter(c int) [][]byte {
  49. var result [][]byte
  50. if c == 32 {
  51. // Space character
  52. result = append(result, []byte{0x20, 0x20})
  53. return result
  54. }
  55. // 33-126 are the possible characters.
  56. if c >= 33 && c <= 126 {
  57. c -= 33
  58. idx := bf.Characters[c]
  59. if idx == -1 {
  60. // This character is not supported by this font.
  61. return result
  62. }
  63. result = bf.Data[bf.Characters[c]]
  64. // fmt.Println("normalizeCharBlock")
  65. normalizeBlock(&result)
  66. // fmt.Println("normalizeChar done")
  67. return result
  68. } else {
  69. return result
  70. }
  71. }
  72. func expandBlock(block *[][]byte) {
  73. // l := len((*block)[0])
  74. l := len((*block)[0])
  75. blank := []byte{0x20}
  76. *block = append(*block, bytes.Repeat(blank, l))
  77. }
  78. // Given text, translate to thedraw font.
  79. func (bf *BlockFont) Output(input string) ([]string, int) {
  80. var out [][]byte
  81. var max int
  82. for _, ch := range input {
  83. // fmt.Printf("%d %x\n", ch, ch)
  84. block := bf.GetCharacter(int(ch))
  85. // fmt.Println("ok")
  86. l := len(block)
  87. max += l
  88. if l != 0 {
  89. if len(out) == 0 {
  90. // First time
  91. out = append(out, block...)
  92. /*
  93. for _, b := range block {
  94. out = append(out, b)
  95. }
  96. */
  97. } else {
  98. if len(out) != 0 {
  99. for l > len(out) {
  100. // We need to expand the out
  101. // fmt.Println("expandBlock")
  102. expandBlock(&out)
  103. }
  104. }
  105. // fmt.Println("Append block to out")
  106. // Ok, we have something!
  107. for idx, b := range block {
  108. out[idx] = append(out[idx], byte(0x20))
  109. out[idx] = append(out[idx], b...)
  110. /*
  111. for _, inner := range b {
  112. out[idx] = append(out[idx], inner)
  113. }
  114. */
  115. // out[idx] += byte(0x20) + b
  116. // fmt.Printf("%s\n", CP437_to_Unicode(b))
  117. }
  118. }
  119. }
  120. // fmt.Println("normalizeBlock")
  121. normalizeBlock(&out)
  122. // fmt.Println("normalizeBlock done")
  123. }
  124. var output []string
  125. for idx := range out {
  126. if Unicode {
  127. output = append(output, CP437_to_Unicode(string(out[idx])))
  128. } else {
  129. output = append(output, string(out[idx]))
  130. }
  131. }
  132. return output, len(out[0])
  133. }
  134. type ColorFont struct {
  135. Characters []int
  136. Data [][][]byte
  137. }
  138. func normalizeColor(block *[][]byte) int {
  139. var max int
  140. for _, line := range *block {
  141. l := len(line)
  142. if max < l {
  143. max = l
  144. }
  145. }
  146. for idx := range *block {
  147. // l := len(line)
  148. blank := []byte{0x20, 0x0f}
  149. for len((*block)[idx]) < max {
  150. (*block)[idx] = append((*block)[idx], blank...)
  151. /*
  152. for _, b := range blank {
  153. (*block)[idx] = append((*block)[idx], b)
  154. }
  155. */
  156. // (*block)[idx] += strings.Repeat(" \x0f", max-l/2)
  157. }
  158. }
  159. return max
  160. }
  161. func (cf *ColorFont) GetCharacter(c int) ([][]byte, int) {
  162. var result [][]byte
  163. if c == 32 {
  164. blank := []byte{0x20, 0x0f, 0x20, 0x0f}
  165. result = append(result, blank) // " \x0f \x0f")
  166. return result, len(result[0]) / 2
  167. }
  168. if c >= 33 && c <= 126 {
  169. c -= 33
  170. idx := cf.Characters[c]
  171. if idx == -1 {
  172. return result, 0
  173. }
  174. result = cf.Data[cf.Characters[c]]
  175. // fmt.Println("Character:")
  176. // BytesArrayHexed(&result)
  177. // fmt.Println("normalizing...")
  178. max := normalizeColor(&result)
  179. // BytesArrayHexed(&result)
  180. // StringHexO(&result)
  181. return result, max
  182. } else {
  183. return result, 0
  184. }
  185. }
  186. func thedraw_to_ansi(c int) int {
  187. trans := []int{0, 4, 2, 6, 1, 5, 3, 7}
  188. // 0, 1, 2, 3, 4, 5, 6, 7
  189. return trans[c]
  190. }
  191. /*
  192. // Before color output was optimized
  193. func colorout(c int) string {
  194. bg := thedraw_to_ansi(c / 16)
  195. fg := c % 16
  196. bold := (fg & 0x8) == 0x8
  197. fg = thedraw_to_ansi(fg & 0x7)
  198. if bold {
  199. return fmt.Sprintf("\x1b[0;1;%d;%dm", fg+30, bg+40)
  200. } else {
  201. return fmt.Sprintf("\x1b[0;%d;%dm", fg+30, bg+40)
  202. }
  203. }
  204. */
  205. type ColorParts struct {
  206. Background int
  207. Foreground int
  208. Bold bool
  209. }
  210. func ColorSplit(color int) ColorParts {
  211. return ColorParts{Background: thedraw_to_ansi(color / 16), Foreground: thedraw_to_ansi(color & 7), Bold: (color%16)&0x08 == 0x08}
  212. }
  213. func ColorOutput(previous int, color int) string {
  214. prev := ColorSplit(previous)
  215. c := ColorSplit(color)
  216. var codes []int8
  217. if c.Bold {
  218. if !prev.Bold {
  219. codes = append(codes, 1)
  220. }
  221. } else {
  222. if prev.Bold {
  223. // bold was set previously, there's only one way to reset it
  224. codes = append(codes, 0)
  225. prev.Background = 0
  226. prev.Foreground = 7
  227. }
  228. }
  229. if prev.Background == 0 && prev.Foreground == 0 {
  230. // output everything
  231. codes = append(codes, int8(c.Foreground)+30)
  232. codes = append(codes, int8(c.Background)+40)
  233. } else {
  234. if c.Foreground != prev.Foreground {
  235. codes = append(codes, int8(c.Foreground)+30)
  236. }
  237. if c.Background != prev.Background {
  238. codes = append(codes, int8(c.Background)+40)
  239. }
  240. }
  241. if len(codes) == 0 {
  242. // Everything matched
  243. return ""
  244. }
  245. var text []string
  246. for _, code := range codes {
  247. text = append(text, strconv.Itoa(int(code)))
  248. }
  249. return "\x1b[" + strings.Join(text, ";") + "m"
  250. }
  251. func Colorize(input []byte) []byte {
  252. var result []byte
  253. // runes := []rune(input)
  254. var previous int
  255. // BytesHexed(input)
  256. for pos := 0; pos < len(input); pos += 2 {
  257. ch := input[pos]
  258. color := int(input[pos+1])
  259. // fmt.Printf("%d : CH %d / %x, Color %d / %x\n", pos, ch, ch, color, color)
  260. colorstring := ColorOutput(previous, color)
  261. result = append(result, []byte(colorstring)...)
  262. /*
  263. for _, c := range []byte(colorstring) {
  264. result = append(result, c)
  265. }
  266. */
  267. // result = append(result, []byte(colorstring))
  268. // result += []byte(ColorOutput(previous, color))
  269. // result += ColorOutput(previous, color) + string(ch)
  270. result = append(result, ch)
  271. // result += string(ch)
  272. previous = color
  273. // result += colorout(color) + string(ch)
  274. }
  275. return result
  276. }
  277. /*
  278. func __expandColor(block *[]string, need int) {
  279. *block = append(*block, strings.Repeat(" \x0f", need))
  280. }
  281. */
  282. func expandColor(block *[][]byte, need int) {
  283. blank := []byte{0x20, 0x0f}
  284. // *block = append(*block, strings.Repeat(" \x0f", need))
  285. *block = append(*block, bytes.Repeat(blank, need))
  286. }
  287. func (bf *ColorFont) Output(input string) ([]string, int) {
  288. var out [][]byte
  289. var max int
  290. for _, ch := range input {
  291. // fmt.Printf("%d %x\n", ch, ch)
  292. block, blklen := bf.GetCharacter(int(ch))
  293. if blklen == 0 {
  294. continue
  295. }
  296. l := len(block)
  297. max += blklen
  298. if l != 0 {
  299. if len(out) == 0 {
  300. // First time
  301. out = append(out, block...)
  302. /*
  303. for _, b := range block {
  304. out = append(out, b)
  305. }
  306. */
  307. } else {
  308. if len(out) != 0 {
  309. for l > len(out) {
  310. // We need to expand the out
  311. expandColor(&out, len(out[0])/2)
  312. // ExpandColor(&out)
  313. }
  314. }
  315. for len(out) > len(block) {
  316. // We need to expand the block out
  317. expandColor(&block, len(block)/2)
  318. }
  319. // Normalizing the character blocks
  320. normalizeColor(&block)
  321. if len(out) != len(block) {
  322. panic(fmt.Sprintf("len(out) %d != len(block) %d", len(out), len(block)))
  323. }
  324. blank := []byte{0x20, 0x0f}
  325. // Ok, we have something!
  326. for idx, b := range block {
  327. /*
  328. out[idx] = append(out[idx], byte(0x20))
  329. out[idx] = append(out[idx], byte(0x0f))
  330. */
  331. out[idx] = append(out[idx], blank...)
  332. out[idx] = append(out[idx], b...)
  333. /*
  334. for _, inner := range b {
  335. out[idx] = append(out[idx], inner)
  336. }
  337. */
  338. //out[idx] += " \x0f" + b
  339. // fmt.Printf("%s\n", CP437_to_Unicode(b))
  340. }
  341. }
  342. // NormalizeColor(&out)
  343. }
  344. }
  345. if len(out) == 0 {
  346. return []string{}, 0
  347. }
  348. // StringHexO(&out)
  349. max = len(out[0]) / 2
  350. for idx := range out {
  351. out[idx] = Colorize(out[idx])
  352. }
  353. var output []string
  354. for idx := range out {
  355. if Unicode {
  356. output = append(output, CP437_to_Unicode(string(out[idx])))
  357. } else {
  358. output = append(output, string(out[idx]))
  359. }
  360. }
  361. return output, max
  362. }
  363. // Given a color to look for, see if it is in the color byte.
  364. // 0x01 = Upper match
  365. // 0x02 = Lower match
  366. func MatchStyle(color byte, look byte) int {
  367. var match int = 0
  368. if ((color >> 4) & 0x07) == look {
  369. // Top
  370. match |= 1
  371. }
  372. if (color & 0x07) == look {
  373. // Bottom
  374. match |= 2
  375. }
  376. return match
  377. }
  378. // Update a color byte with the new color information.
  379. // Style 0x01 = Upper, 0x02 = Lower, 0x03 = Both.
  380. func PatchColor(color byte, new_color byte, style int) byte {
  381. var c byte = color
  382. if style&1 == 1 {
  383. c = (c & 0x8f) | new_color<<4
  384. }
  385. if style&2 == 2 {
  386. c = (c & 0xf8) | new_color
  387. }
  388. return c
  389. }
  390. // Scan a ColorFont for a specific color.
  391. // This returns a map key of character Index + line Index
  392. // with an array of [2]int (Index, Style) to change.
  393. func (cf *ColorFont) Scan(find_color int) map[[2]int][][2]int {
  394. var Targets map[[2]int][][2]int = make(map[[2]int][][2]int, 0)
  395. // Scan the font looking for the given color FG/BG
  396. // Covert color code to TheDraw Color
  397. actual := byte(thedraw_to_ansi(find_color))
  398. for charIndex := range cf.Data {
  399. for lineIndex := range cf.Data[charIndex] {
  400. var found bool = false
  401. var patches [][2]int = make([][2]int, 0)
  402. for offset := 1; offset < len(cf.Data[charIndex][lineIndex]); offset += 2 {
  403. color := cf.Data[charIndex][lineIndex][offset]
  404. style := MatchStyle(color, actual)
  405. if style != 0 {
  406. // log.Printf("color: %x actual %x style: %d\n", color, actual, style)
  407. patches = append(patches, [2]int{offset, style})
  408. found = true
  409. }
  410. }
  411. if found {
  412. pos := [2]int{charIndex, lineIndex}
  413. Targets[pos] = make([][2]int, len(patches))
  414. for i := range patches {
  415. Targets[pos][i] = patches[i]
  416. }
  417. // Targets[pos] = patches
  418. }
  419. }
  420. }
  421. return Targets
  422. }
  423. // This modifies the font color, using the Targets found with
  424. // Scan.
  425. func (cf *ColorFont) Modify(new_color int, Targets map[[2]int][][2]int) {
  426. // Covert color code to TheDraw Color
  427. actual := byte(thedraw_to_ansi(new_color))
  428. for pos, patch := range Targets {
  429. for _, p := range patch {
  430. cf.Data[pos[0]][pos[1]][p[0]] = PatchColor(cf.Data[pos[0]][pos[1]][p[0]], actual, p[1])
  431. }
  432. }
  433. }
  434. /*
  435. func CP437Bytes_to_Unicode(cp437 []byte) string {
  436. var result string
  437. for _, char := range cp437 {
  438. // fmt.Printf("%d, %x ", char, char)
  439. switch int(char) {
  440. case 0x01:
  441. result += "\u263A"
  442. case 0x02:
  443. result += "\u263B"
  444. case 0x03:
  445. result += "\u2665"
  446. case 0x04:
  447. result += "\u2666"
  448. case 0x05:
  449. result += "\u2663"
  450. case 0x06:
  451. result += "\u2660"
  452. case 0x09:
  453. result += "\u25CB"
  454. case 0x0b:
  455. result += "\u2642"
  456. case 0x0c:
  457. result += "\u2640"
  458. case 0x0e:
  459. result += "\u266B"
  460. case 0x0f:
  461. result += "\u263C"
  462. case 0x10:
  463. result += "\u25BA"
  464. case 0x11:
  465. result += "\u25C4"
  466. case 0x12:
  467. result += "\u2195"
  468. case 0x13:
  469. result += "\u203C"
  470. case 0x14:
  471. result += "\xc2\xb6"
  472. case 0x15:
  473. result += "\xc2\xa7"
  474. case 0x16:
  475. result += "\u25AC"
  476. case 0x17:
  477. result += "\u21A8"
  478. case 0x18:
  479. result += "\u2191"
  480. case 0x19:
  481. result += "\u2193"
  482. case 0x1a:
  483. result += "\u2192"
  484. case 0x1c:
  485. result += "\u221F"
  486. case 0x1d:
  487. result += "\u2194"
  488. case 0x1e:
  489. result += "\u25B2"
  490. case 0x1f:
  491. result += "\u25BC"
  492. case 0x7f:
  493. result += "\u2302"
  494. case 0x80:
  495. result += "\xc3\x87"
  496. case 0x81:
  497. result += "\xc3\xbc"
  498. case 0x82:
  499. result += "\xc3\xa9"
  500. case 0x83:
  501. result += "\xc3\xa2"
  502. case 0x84:
  503. result += "\xc3\xa4"
  504. case 0x85:
  505. result += "\xc3\xa0"
  506. case 0x86:
  507. result += "\xc3\xa5"
  508. case 0x87:
  509. result += "\xc3\xa7"
  510. case 0x88:
  511. result += "\xc3\xaa"
  512. case 0x89:
  513. result += "\xc3\xab"
  514. case 0x8a:
  515. result += "\xc3\xa8"
  516. case 0x8b:
  517. result += "\xc3\xaf"
  518. case 0x8c:
  519. result += "\xc3\xae"
  520. case 0x8d:
  521. result += "\xc3\xac"
  522. case 0x8e:
  523. result += "\xc3\x84"
  524. case 0x8f:
  525. result += "\xc3\x85"
  526. case 0x90:
  527. result += "\xc3\x89"
  528. case 0x91:
  529. result += "\xc3\xa6"
  530. case 0x92:
  531. result += "\xc3\x86"
  532. case 0x93:
  533. result += "\xc3\xb4"
  534. case 0x94:
  535. result += "\xc3\xb6"
  536. case 0x95:
  537. result += "\xc3\xb2"
  538. case 0x96:
  539. result += "\xc3\xbb"
  540. case 0x97:
  541. result += "\xc3\xb9"
  542. case 0x98:
  543. result += "\xc3\xbf"
  544. case 0x99:
  545. result += "\xc3\x96"
  546. case 0x9a:
  547. result += "\xc3\x9c"
  548. case 0x9b:
  549. result += "\xc2\xa2"
  550. case 0x9c:
  551. result += "\xc2\xa3"
  552. case 0x9d:
  553. result += "\xc2\xa5"
  554. case 0x9e:
  555. result += "\u20A7"
  556. case 0x9f:
  557. result += "\u0192"
  558. case 0xa0:
  559. result += "\xc3\xa1"
  560. case 0xa1:
  561. result += "\xc3\xad"
  562. case 0xa2:
  563. result += "\xc3\xb3"
  564. case 0xa3:
  565. result += "\xc3\xba"
  566. case 0xa4:
  567. result += "\xc3\xb1"
  568. case 0xa5:
  569. result += "\xc3\x91"
  570. case 0xa6:
  571. result += "\xc2\xaa"
  572. case 0xa7:
  573. result += "\xc2\xba"
  574. case 0xa8:
  575. result += "\xc2\xbf"
  576. case 0xa9:
  577. result += "\u2310"
  578. case 0xaa:
  579. result += "\xc2\xac"
  580. case 0xab:
  581. result += "\xc2\xbd"
  582. case 0xac:
  583. result += "\xc2\xbc"
  584. case 0xad:
  585. result += "\xc2\xa1"
  586. case 0xae:
  587. result += "\xc2\xab"
  588. case 0xaf:
  589. result += "\xc2\xbb"
  590. case 0xb0:
  591. result += "\u2591"
  592. case 0xb1:
  593. result += "\u2592"
  594. case 0xb2:
  595. result += "\u2593"
  596. case 0xb3:
  597. result += "\u2502"
  598. case 0xb4:
  599. result += "\u2524"
  600. case 0xb5:
  601. result += "\u2561"
  602. case 0xb6:
  603. result += "\u2562"
  604. case 0xb7:
  605. result += "\u2556"
  606. case 0xb8:
  607. result += "\u2555"
  608. case 0xb9:
  609. result += "\u2563"
  610. case 0xba:
  611. result += "\u2551"
  612. case 0xbb:
  613. result += "\u2557"
  614. case 0xbc:
  615. result += "\u255D"
  616. case 0xbd:
  617. result += "\u255C"
  618. case 0xbe:
  619. result += "\u255B"
  620. case 0xbf:
  621. result += "\u2510"
  622. case 0xc0:
  623. result += "\u2514"
  624. case 0xc1:
  625. result += "\u2534"
  626. case 0xc2:
  627. result += "\u252C"
  628. case 0xc3:
  629. result += "\u251C"
  630. case 0xc4:
  631. result += "\u2500"
  632. case 0xc5:
  633. result += "\u253C"
  634. case 0xc6:
  635. result += "\u255E"
  636. case 0xc7:
  637. result += "\u255F"
  638. case 0xc8:
  639. result += "\u255A"
  640. case 0xc9:
  641. result += "\u2554"
  642. case 0xca:
  643. result += "\u2569"
  644. case 0xcb:
  645. result += "\u2566"
  646. case 0xcc:
  647. result += "\u2560"
  648. case 0xcd:
  649. result += "\u2550"
  650. case 0xce:
  651. result += "\u256C"
  652. case 0xcf:
  653. result += "\u2567"
  654. case 0xd0:
  655. result += "\u2568"
  656. case 0xd1:
  657. result += "\u2564"
  658. case 0xd2:
  659. result += "\u2565"
  660. case 0xd3:
  661. result += "\u2559"
  662. case 0xd4:
  663. result += "\u2558"
  664. case 0xd5:
  665. result += "\u2552"
  666. case 0xd6:
  667. result += "\u2553"
  668. case 0xd7:
  669. result += "\u256B"
  670. case 0xd8:
  671. result += "\u256A"
  672. case 0xd9:
  673. result += "\u2518"
  674. case 0xda:
  675. result += "\u250C"
  676. case 0xdb:
  677. result += "\u2588"
  678. case 0xdc:
  679. result += "\u2584"
  680. case 0xdd:
  681. result += "\u258C"
  682. case 0xde:
  683. result += "\u2590"
  684. case 0xdf:
  685. result += "\u2580"
  686. case 0xe0:
  687. result += "\u03B1"
  688. case 0xe1:
  689. result += "\xc3\x9f"
  690. case 0xe2:
  691. result += "\u0393"
  692. case 0xe3:
  693. result += "\u03C0"
  694. case 0xe4:
  695. result += "\u03A3"
  696. case 0xe5:
  697. result += "\u03C3"
  698. case 0xe6:
  699. result += "\xc2\xb5"
  700. case 0xe7:
  701. result += "\u03C4"
  702. case 0xe8:
  703. result += "\u03A6"
  704. case 0xe9:
  705. result += "\u0398"
  706. case 0xea:
  707. result += "\u03A9"
  708. case 0xeb:
  709. result += "\u03B4"
  710. case 0xec:
  711. result += "\u221E"
  712. case 0xed:
  713. result += "\u03C6"
  714. case 0xee:
  715. result += "\u03B5"
  716. case 0xef:
  717. result += "\u2229"
  718. case 0xf0:
  719. result += "\u2261"
  720. case 0xf1:
  721. result += "\xc2\xb1"
  722. case 0xf2:
  723. result += "\u2265"
  724. case 0xf3:
  725. result += "\u2264"
  726. case 0xf4:
  727. result += "\u2320"
  728. case 0xf5:
  729. result += "\u2321"
  730. case 0xf6:
  731. result += "\xc3\xb7"
  732. case 0xf7:
  733. result += "\u2248"
  734. case 0xf8:
  735. result += "\xc2\xb0"
  736. case 0xf9:
  737. result += "\u2219"
  738. case 0xfa:
  739. result += "\xc2\xb7"
  740. case 0xfb:
  741. result += "\u221A"
  742. case 0xfc:
  743. result += "\u207F"
  744. case 0xfd:
  745. result += "\xc2\xb2"
  746. case 0xfe:
  747. result += "\u25A0"
  748. case 0xff:
  749. result += "\xc2\xa0"
  750. default:
  751. result += string(char)
  752. }
  753. }
  754. // fmt.Printf("\n")
  755. return result
  756. }
  757. */