Cannot convert string to char. That’s my problem right now. I don’t know why it can’t, it isn’t like it is a terribly difficult to do… but anyway, all I want is this:
var nothin : char = '\0';
That should work but doesn’t. My usual workaround for declaring chars is to say
var charX : char = "X"[0];
which will obviously not work in this case. So what will?
Are you using a literal value like in your example? I'm not understanding why the second method won't work for you.
I don't want '0,' I want backslash-zero, which is a null character. I'm trying to filter textfield input so that all special characters are ignored. In the second example, that's picking the first character out of a string; if I tried to say "\0"[0] I would just get the character "\".
I don't think you understand - char values can be represented by interger values. [According to this table][1] the value you want is represented by the number 0. Here's an experiment for you to try out. Look at the table. According to it, decimal value 65 = 'A'. Let's do this: var c : char = 65; Debug.Log(c); What do you get? [1]: http://www.asciitable.com/
@Eric5h5, did you even read what I said? I said 0 is the integer value for the null character; they are the same. Look at the link I posted. I'm very aware of what the null character is. Loius' answer was just as correct as yours; arguably more correct because it's cleaner. If neither of you understand, then try the snippet I posted.
"\0" is a single character, even though it looks like two characters. So
var nada = "\0"[0];
is correct. You can’t type "\" by itself and get a backslash character, since the backslash is an escape character. In order to actually use "\" as a char, you’d need to do
Are you using a literal value like in your example? I'm not understanding why the second method won't work for you.
– hoy_smallfryI don't want '0,' I want backslash-zero, which is a null character. I'm trying to filter textfield input so that all special characters are ignored. In the second example, that's picking the first character out of a string; if I tried to say
– Kiloblargh"\0"[0]I would just get the character"\".I don't think you understand -
– hoy_smallfrycharvalues can be represented by interger values. [According to this table][1] the value you want is represented by the number 0. Here's an experiment for you to try out. Look at the table. According to it, decimal value 65 = 'A'. Let's do this: var c : char = 65; Debug.Log(c); What do you get? [1]: http://www.asciitable.com/Guys,
– Eric5h5"\0"is a null character. This isn't about literal backslashes or zeroes.@Eric5h5, did you even read what I said? I said 0 is the integer value for the null character; they are the same. Look at the link I posted. I'm very aware of what the null character is. Loius' answer was just as correct as yours; arguably more correct because it's cleaner. If neither of you understand, then try the snippet I posted.
– hoy_smallfry