Solved

Converting  guid as a null-termintated string binary to hex

Posted on 2014-01-09
2
841 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is a security feature on iOS devices that is nearly impenetrable when it has been activated.  This article will provide some possible solutions as well as necessary steps to take to ensure you do not end up with a locked device.
In this article we will discuss some EI Capitan Mail app issues and provide some manual process to resolve them.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

726 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