string[] strVarArr = strVar.Split('x'); - Empty character literal error

G

gvanosdol

When on my development machine, I can execute the code in the subject
(string[] strVarArr = strVar.Split('x');) without any problems. When I
try to move the code to my server, I get "CS1011: Empty character
literal."

I thought perhaps it was a font issue, but I verified that the font is
available on the server, that the character codes are the same, and
that the sql character set is the same in both places.

I'm sure this is covered somewhere, but I've been unable to form a
proper query in google to come up with an answer.

I'm using ASP.NET C# 2.0x, running on IIS 6

Any help is greatly appreciated.

thanks,

g
 
J

Jon Skeet [C# MVP]

When on my development machine, I can execute the code in the subject
(string[] strVarArr = strVar.Split('x');) without any problems. When I
try to move the code to my server, I get "CS1011: Empty character
literal."

I thought perhaps it was a font issue, but I verified that the font is
available on the server, that the character codes are the same, and
that the sql character set is the same in both places.

I'm sure this is covered somewhere, but I've been unable to form a
proper query in google to come up with an answer.

I'm using ASP.NET C# 2.0x, running on IIS 6

I can't see how fonts could have anything to do with it. My guess is
that in moving the code over you've changed it to:

string[] strVarArr = strVar.Split('');
 
B

Bobbo

When on my development machine, I can execute the code in the subject
(string[] strVarArr = strVar.Split('x');) without any problems. When I
try to move the code to my server, I get "CS1011: Empty character
literal."

Is this the actual code you're using or demo code?

i.e. Is the code on your server really using 'x' as the parameter or
is it obtaining it from somewhere else?
 
G

gvanosdol

When on my development machine, I can execute the code in the subject
(string[] strVarArr = strVar.Split('x');) without any problems. When I
try to move the code to my server, I get "CS1011: Empty character
literal."

Is this the actual code you're using or demo code?

i.e. Is the code on your server really using 'x' as the parameter or
is it obtaining it from somewhere else?

It is a literal character in the split statement (using single
quotation marks). The actual character is "¶". (U+00B6 or "pilcrow
sign" in window's character map).
 
J

Jon Skeet [C# MVP]

It is a literal character in the split statement (using single
quotation marks). The actual character is "¶". (U+00B6 or "pilcrow
sign" in window's character map).

How are you representing that in the code?
 
G

gvanosdol

How are you representing that in the code?

like this...

string[] strVarArr = strVar.Split('¶');

in your original reply, you mentioned that maybe the character wasn't
there on the server, but the error message actually displays the
character when it's telling me that there's no character.

thanks.

g
 
J

Jon Skeet [C# MVP]

How are you representing that in the code?
like this...

string[] strVarArr = strVar.Split('¶');

in your original reply, you mentioned that maybe the character wasn't
there on the server, but the error message actually displays the
character when it's telling me that there's no character.

It could well be an encoding issue. I suggest you use:
string[] strVarArr = strVar.Split('\u00b6');
 
G

gvanosdol

like this...
string[] strVarArr = strVar.Split('¶');
in your original reply, you mentioned that maybe the character wasn't
there on the server, but the error message actually displays the
character when it's telling me that there's no character.

It could well be an encoding issue. I suggest you use:
string[] strVarArr = strVar.Split('\u00b6');

I'll try that. I thought about it, but didn't know the syntax. I'll
reply after I give it a shot.

txs.
 
G

gvanosdol

How are you representing that in the code?
like this...
string[] strVarArr = strVar.Split('¶');
in your original reply, you mentioned that maybe the character wasn't
there on the server, but the error message actually displays the
character when it's telling me that there's no character.
It could well be an encoding issue. I suggest you use:
string[] strVarArr = strVar.Split('\u00b6');

I'll try that. I thought about it, but didn't know the syntax. I'll
reply after I give it a shot.

txs.

thanks much. it worked. not that it matters at this point, but why do
you suppose that would happen even though it had the same character
code on both machines?
 
J

Jon Skeet [C# MVP]

thanks much. it worked. not that it matters at this point, but why do
you suppose that would happen even though it had the same character
code on both machines?

Different machines may have different default encodings. In general,
embedding non-ascii characters directly in source code is a problem
waiting to happen.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top