Re: Character representation

From: Chad Myers (cmyers_at_N0.SP4M.austin.rr.com)
Date: 10/08/04


Date: Fri, 08 Oct 2004 15:51:45 GMT


"Gas" <gasxxx@hotmail.com> wrote in message
news:ukv7nvUrEHA.2732@TK2MSFTNGP09.phx.gbl...
> Hi,
>
> I am wondering how can I representation some of the specical characters in
> C#?
> (for example, we use vbKeyTab for Tab and vbCrLf for line feed in VB)
>
> Also is there any character to ASCII code and ASCII code to character
> built-in function in C#?

\r = carriage return
\n = linefeed (\r\n = vbCrLf)
\t = tab
\" = double quote

There are a few other esoteric ones, but those are the most common.

As far as char-to-code and vice versa:

// code will be 32 or 0x20
int code = (int) ' ';

// spaceChar will be ' '
char spaceChar = (char) 32;

Please be aware that strings and chars in .NET are Unicode. If you hit
some special unicode characters or other languages and such, you may
get unexpected results. In general, you should try to avoid worring about
what the ASCII code is for a given char because it's not reliable in an
internationalized sense.

-c



Relevant Pages

  • Re: Option Explicit bug?
    ... Also, encryption in general can lead to characters with ASCII code 0, so you ... that it does not return 0 for any char. ...
    (microsoft.public.vb.general.discussion)
  • Re: heeeeeeeeeeeeeeeellllllllllllllppppppppppppppppppppp
    ... Why is using char* a bad thing and why using sprintf a bad thing to, ... can be up to MAX_PATH characters). ... LPSTR lpMsgBuf; ... MessageBox(NULL, lpMsgBuf, "GetLastError() for ...
    (microsoft.public.vc.mfc)
  • Re: heeeeeeeeeeeeeeeellllllllllllllppppppppppppppppppppp
    ... This means that if you develop the bad habit of using char * (left over ... It usually takes me five minutes to create a Unicode version of any of my apps, ... BOOL and bool are different data types. ... can be up to MAX_PATH characters). ...
    (microsoft.public.vc.mfc)
  • Re: Great SWT Program
    ... Vim -- car is fixed, ... and/or press tab again to get a list of choices. ... to type one or more additional characters and press tab again. ...
    (comp.lang.java.programmer)
  • Re: Decatenate a field with Make Table Query?
    ... You can probably do something similar in MS Word, lining them up using tab characters in ordinary paragraphs. ... You can use Word to delete lines that contain only white space, and you can delete repeated paragraph marks. ... I would define a special paragraph style that would include the tab settings for this operation, but would not save it in the global Word template, as you'll likely never need this style again, so leave "Add to Template" unchecked, but check "Automatically Update". ... In the Excel cell the paragraph marks show up as bangs; ...
    (microsoft.public.access.queries)