0

I'm trying to create a Backgammon game board using Unicode graphics with an array back-end. For example; White Draughts Man: U+26C0 to represent checkers on a slot. What do I need to do to make this work ?

I've tried using ChrW() with the Unicode that is given from a Unicode table elsewhere

PS: This code is from a test application before adding to my actual assignment. I just receive an error.

Sub Main()
    Console.OutputEncoding = System.Text.Encoding.Unicode
    Console.WriteLine(ChrW(&H26C0))
    Console.ReadKey()
End Sub
Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
eren230
  • 1
  • 3
  • Have you tried this https://stackoverflow.com/questions/3144053/how-to-represent-unicode-chr-code-in-vb-net-string-literal ? – Benno Grimm Feb 03 '19 at 15:08
  • You should tell us what the error is. For example, a hexadecimal literal in VB.NET would look like `&H26C0`. I suspect you are getting an error like "'U26C0' is not declared..." because that is the name of a variable. – Andrew Morton Feb 03 '19 at 15:35
  • So with updated code, I get the Question Mark in a box rather than the unicode graphic I want to be displayed - code updated in thread start – eren230 Feb 03 '19 at 16:56
  • @eren230 I don't think that particular character is available in any of the fonts which can be set in the console. I suggest using a suitable background colour and an "o" in black or white as needed. – Andrew Morton Feb 03 '19 at 17:00
  • @AndrewMorton Apparently, I can also convert this into a Windows form project and use a textbox as my interface with the same premises ? And the unicode graphics will also work with this method but im not 100% on what to do in that case. thanks for the input – eren230 Feb 03 '19 at 17:02
  • @eren230 I recommend that you make it work before making it look pretty ;) – Andrew Morton Feb 03 '19 at 17:12
  • @AndrewMorton haha yeah, that's the plan but was just mentioning that this Unicode graphic idea would work in Windows App or so I've been told. gonna try your idea ! – eren230 Feb 03 '19 at 17:16
  • `"⛀"` works just as well as `ChrW(&H26C0)`, unless your source files aren't in the default UTF-8 encoding of Unicode (but then you'd be telling your compiler which you are using, regardless of the characters used, right?). – Tom Blodget Feb 03 '19 at 17:25
  • 2
    You need to select a font for the console that can display this glyph. That is very tough shopping for U+26C0 since you need a fixed-pitch font. Run the Charmap.exe applet to see that for yourself. – Hans Passant Feb 03 '19 at 17:48
  • @HansPassant So i changed the font to NSimSun on the properties option on the console window and it worked. Now need to find out how to increase their size as the font size increase doesn't seem to work – eren230 Feb 04 '19 at 10:16
  • @AndrewMorton See above, I changed the font in the properties window (click on cmd symbol in top left when running) to NSimSun - I'm sure some other fonts will also work but that's the only one I tried – eren230 Feb 04 '19 at 10:19

0 Answers0