Solved

Converting  guid as a null-termintated string binary to hex

Posted on 2014-01-09
2
812 Views
Last Modified: 2016-02-29
Hi All,

I have a GUID : 373D06E9-587E-4930-B846-12500FF1AC2F which needs to be converted into hexadecimal using Cocoa or objective C.



Can some one please let me know how to do that.

Thanks,
Ravi
0
Comment
Question by:rkankula
2 Comments
 
LVL 33

Accepted Solution

by:
pgnatyuk earned 500 total points
ID: 39770610
GUID is 128-bit value displayed as 32 hexadecimal digits.
I hope this example will help you:
        NSString *source = @"373D06E9-587E-4930-B846-12500FF1AC2F";
        NSString *line = [source stringByReplacingOccurrencesOfString:@"-" withString:@""];
        NSUInteger length = [line length];
        
        NSUInteger cnt = 0;
        unichar symbols[2];
        while ( cnt < length ) {
            symbols[0] = [line characterAtIndex:cnt];
            symbols[1] = [line characterAtIndex:cnt + 1];
            NSString *one = [NSString stringWithCharacters:symbols length:2];
            
            NSScanner *scanner = [NSScanner scannerWithString:one];
            unsigned hexNum;
            [scanner scanHexInt:&hexNum];
            
            NSLog(@"0x%@ %i", one, hexNum);
            
            cnt += 2;
        }

Open in new window

0
 

Author Closing Comment

by:rkankula
ID: 39771771
Thanks this will be helpful
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

What's a UDID? If you're involved in developing, testing, or even reviewing an iOS application that's in beta, then at some point you may need to know the UDID for any iOS devices that you'll be testing on. What's the UDID? It stands for Unique Dev…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now