0

Having trouble with character types...

protected void Page_Load(object sender, EventArgs e)
{
    char test = '\ue900'; //This makes test = 59648'.'
}

However, this doesn't work:

protected void Page_Load(object sender, EventArgs e)
{        
    char test = '\f000'; 
    //This won't compile because squiggly on test says "Too many characters in literal"        
    //However, this works when I put the value in CSS content attribute.
}

How do I make the latter fit into the test variable? I think in the first example, it's a unicode value and in the second it's not?

Rod
  • 14,529
  • 31
  • 118
  • 230
  • have you tried `"\f000"` ? – Koby Douek Mar 24 '17 at 18:44
  • I think that because that char is 2 bytes, you should use "" – Koby Douek Mar 24 '17 at 18:45
  • Possible duplicate of ["Too many characters in character literal error"](http://stackoverflow.com/questions/5606664/too-many-characters-in-character-literal-error) – Tyler Roper Mar 24 '17 at 18:46
  • 1
    What do you expect 'f000' to represent? c# supports [Unicode character escape sequences](https://msdn.microsoft.com/en-us/library/aa664669(v=vs.71).aspx) which start with `'\u'`, and it supports [hexadecimal escape sequences](https://msdn.microsoft.com/en-us/library/aa691087(v=vs.71).aspx) that start with `'\x'`. An example of each is on the [MSDN page for char](https://msdn.microsoft.com/en-us/library/x9h8tsay.aspx). – Quantic Mar 24 '17 at 18:47
  • '\f000' is content value from FontAwesome. http://astronautweb.co/snippet/font-awesome/ – Rod Mar 24 '17 at 18:51
  • You should add a `fontawesome` tag because I believe this question is about how to use FontAwesome specifically and I think you'll have better luck with an answer. This is out of my scope of knowledge but according to [this page](https://github.com/awesome-inc/FontAwesome.Sharp) you need to be using [this cheat sheet](http://fontawesome.io/cheatsheet/) and it appears you use strings, not chars, as in their example: ` – Quantic Mar 24 '17 at 19:00

2 Answers2

0

I believe \f is form-feed, so it being suffixed exceeds the scope of a single char literal.

schulmaster
  • 413
  • 5
  • 16
0

\u is the notation of specifying a unicode character in the c#. The \u is followed by a hexadecimal value, more on that here

So first code compiles because you are specifying one character but in second code, you have 4 characters which are \f escape sequence and three zeroes. And that is why it doesn't compile.

Selman Genç
  • 100,147
  • 13
  • 119
  • 184