Click here to Skip to main content
12,253,679 members (59,294 online)
   

C#

 
QuestionString implementation in .NET Framework Pin
J4amieC4-Nov-08 3:38
mvpJ4amieC4-Nov-08 3:38 
AnswerRe: String implementation in .NET Framework Pin
Ennis Ray Lynch, Jr.4-Nov-08 4:06
memberEnnis Ray Lynch, Jr.4-Nov-08 4:06 
GeneralRe: String implementation in .NET Framework Pin
J4amieC4-Nov-08 4:12
mvpJ4amieC4-Nov-08 4:12 
GeneralRe: String implementation in .NET Framework Pin
Ennis Ray Lynch, Jr.4-Nov-08 4:18
memberEnnis Ray Lynch, Jr.4-Nov-08 4:18 
GeneralRe: String implementation in .NET Framework Pin
J4amieC4-Nov-08 5:25
mvpJ4amieC4-Nov-08 5:25 
GeneralRe: String implementation in .NET Framework Pin
DaveyM694-Nov-08 4:32
memberDaveyM694-Nov-08 4:32 
GeneralRe: String implementation in .NET Framework Pin
J4amieC4-Nov-08 5:26
mvpJ4amieC4-Nov-08 5:26 
GeneralRe: String implementation in .NET Framework Pin
DaveyM694-Nov-08 5:32
memberDaveyM694-Nov-08 5:32 
AnswerRe: String implementation in .NET Framework Pin
PIEBALDconsult4-Nov-08 4:34
memberPIEBALDconsult4-Nov-08 4:34 
J4amieC wrote:
As you can see, simple code & easy to port but very different results


No, I can't see; what are the results?



Provided you don't care about Unicode, you could use:

System.Text.Encoding.ASCII.GetBytes()

and

System.Text.Encoding.ASCII.GetString()


You could also access the characters in an unsafe context much like your VB code. Something like:

private unsafe static void
ASCIIize
(
    string Subject
)
{
    fixed ( char* subject = Subject )
    {
        int* length = (int*) subject - 1 ;
        int  index  = 0 ;
 
        while ( index < *length )
        {
            *(subject + index) &= (char) 0x7F ;
 
            index++ ;
        }
    }
 
    return ;
}

(Though I haven't tested this with the problematic characters.)
GeneralRe: String implementation in .NET Framework Pin
J4amieC4-Nov-08 5:28
mvpJ4amieC4-Nov-08 5:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 6 May 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid