Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

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

0 views
Skip to first unread message

gvan...@gmail.com

unread,
Feb 15, 2007, 11:45:22 PM2/15/07
to
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

Jon Skeet [C# MVP]

unread,
Feb 16, 2007, 2:33:33 AM2/16/07
to

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('');

--
Jon Skeet - <sk...@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Bobbo

unread,
Feb 16, 2007, 6:15:21 AM2/16/07
to
On 16 Feb, 04:45, gvanos...@gmail.com wrote:
> 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?

gvan...@gmail.com

unread,
Feb 16, 2007, 4:20:22 PM2/16/07
to

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).

Jon Skeet [C# MVP]

unread,
Feb 16, 2007, 4:40:37 PM2/16/07
to
<gvan...@gmail.com> wrote:
> > 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).

How are you representing that in the code?

gvan...@gmail.com

unread,
Feb 16, 2007, 4:52:35 PM2/16/07
to
On Feb 16, 4:40 pm, Jon Skeet [C# MVP] <s...@pobox.com> wrote:

> <gvanos...@gmail.com> wrote:
> > > 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).
>
> How are you representing that in the code?
>
> --
> Jon Skeet - <s...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet

> If replying to the group, please do not mail me too

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

Jon Skeet [C# MVP]

unread,
Feb 16, 2007, 4:59:11 PM2/16/07
to
<gvan...@gmail.com> wrote:
> > 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');

--
Jon Skeet - <sk...@pobox.com>

gvan...@gmail.com

unread,
Feb 16, 2007, 5:25:43 PM2/16/07
to
On Feb 16, 4:59 pm, Jon Skeet [C# MVP] <s...@pobox.com> wrote:

> <gvanos...@gmail.com> wrote:
> > > 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');
>
> --
> Jon Skeet - <s...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet

> If replying to the group, please do not mail me too

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

txs.

gvan...@gmail.com

unread,
Feb 16, 2007, 5:48:46 PM2/16/07
to

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?

Jon Skeet [C# MVP]

unread,
Feb 17, 2007, 8:48:01 AM2/17/07
to
<gvan...@gmail.com> wrote:
> 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.

--
Jon Skeet - <sk...@pobox.com>

0 new messages