473,667 Members | 2,524 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting GUIDs to base-36

I've got an application that generates GUIDs. A lot of GUIDs. Lots
of GUIDs that end up in files on disk, taking up space. I'd like to
continue using the Guid.NewGuid() function as my unique tag generator,
but I'd also like to compress them to base 36 strings, which should
retain their uniqueness but save me disk space. I've looked at
various base conversion functions, and haven't found a suitable one.
Further, I don't need an AnyBase converter. I need a very specific
thing: a base-16 string to base-36 string converter. Anything
additional would be a waste. Can somebody help me fill in the blanks
below?

static string MakeGuid36()
{
//make a new guid
Guid g = Guid.NewGuid();

//convert the guid to a base-16 string
string strGuid = g.ToString().Re place("-", "");

//convert the base-16 string to a base-36 string
??

//return the result
return strGuid;
}
Nov 16 '05 #1
1 10898
Here's some C code to do what you want. You'll have to write a function to
handle 'words' but this is a fast way to do the character level conversion:

/*************** *************** *************** *************** ***************
*
return a base 36 character. v must be from 0 to 35.
*************** *************** *************** *************** *************** *
/
static char base36(unsigned int v)
{
static char basechars[] = "0123456789ABCD EFGHIJKLMNOPQRS TUVWXYZ";
return basechars[v % 36];
}

You can see the whole file here:
http://www.koders.com/c/fidAE1343A83....aspx?s=base36

"vector" <is****@yahoo.c om> wrote in message
news:79******** *************** ***@posting.goo gle.com...
I've got an application that generates GUIDs. A lot of GUIDs. Lots
of GUIDs that end up in files on disk, taking up space. I'd like to
continue using the Guid.NewGuid() function as my unique tag generator,
but I'd also like to compress them to base 36 strings, which should
retain their uniqueness but save me disk space. I've looked at
various base conversion functions, and haven't found a suitable one.
Further, I don't need an AnyBase converter. I need a very specific
thing: a base-16 string to base-36 string converter. Anything
additional would be a waste. Can somebody help me fill in the blanks
below?

static string MakeGuid36()
{
//make a new guid
Guid g = Guid.NewGuid();

//convert the guid to a base-16 string
string strGuid = g.ToString().Re place("-", "");

//convert the base-16 string to a base-36 string
??

//return the result
return strGuid;
}

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1357
by: Shaun Clark | last post by:
Hello, I am trying to bring my entire organization from a Microsoft platform to a Linux one, starting with all of the servers we are currently running. Sun ONE ASP allows me to run ASP on Linux through Apache, Mono is working on .NET, but the one thing I can't migrate is SQL and it's because products like mySQL and Postgres have no built-in GUID support. We have 100 databases with GUIDs as primary keys across all of them. It works great...
14
2717
by: David Wheeler | last post by:
Hi All, I want to use GUIDs for object IDs in my application. This means that they would be used for primary keys in PostgreSQL, and there would of course be FKs pointing to them. A GUID is 128 bits, and can be in the following possible formats: * 16 byte binary (but then I'd have to convert it to hex in my app) * 32 byte string (e.g., '4162F7121DD211B2B17EC09EFE1DC403') * hex string (e.g., 0x3271839C163D11D891F785398CC7932E)
4
33923
by: J.Marsch | last post by:
I notice that when I generate various guids, they appear to have a mix of upper and lowercase letters. Is the uniqueness of a guid case-sensitive? In other words, if I generate a guid, and then store it in a database that is case insensitive (or if I convert the letters to upper), is it still statistically unique?
11
7257
by: Jeff | last post by:
Hi - I'm experiencing a strange problem when comparing 2 guids. In my trial, they're not equal. When I step through the (VB.NET) code, they are evaluated as equal, and when I enter the comparison in the command window, they're not equal. I'm pretty stumped on this one. Please help. I've tried the following structures, all with the same result: guid1.equals(guid2)
2
1151
by: Howard Kaikow | last post by:
Being lazy, I sometimes copy a project to another directory, then tweak the code. A problem arises because then both projects have identical GUIDs in the .sln file, and in the assembly file. Is there any way to change the GUIDs, other than by overcoming my laziness and creating a New Project instead of copying the files? --
3
1430
by: Michael | last post by:
Hi All, I need a little help converting a class to vb.net. I have the following to convert: internal class BBBSDIForm : BBBForm { public BBBSDIForm(FormInfo fi, FormMgr formMgr) : base(fi, formMgr) { sysform=new SmartForm(formMgr, this, fi.pos); sysform.Text=fi.caption; sysform.ClientSize=fi.size;
3
4434
by: dew | last post by:
I have a stored procedure that retrieves the id of a client table, which is a guid To get that id, I have dim clientid as guid = GetClientID("OrgName") The GetClientID returns a string, because sometimes it's not a guid, but in this procedure it is. How do I convert the GetClientID into a Guid? I tried
13
3953
by: Paraic Gallagher | last post by:
Hi, This is my first post to the list, I hope somebody can help me with this problem. Apologies if it has been posted before but I have been internet searching to no avail. What I am trying to do is provide a simple method for a user to change a config file, for a test suite. The config file consists of a number of keys, eg. build number, target device, etc.
9
2565
by: Terry | last post by:
I am converting (attempting) some vb6 code that makes vast use of interfaces. One of the major uses is to be able to split out Read-only access to an obect. Let me give you a simple (contrived) example: In Project RoObjDefs: RoPerson.cls file: Public Property Get FirstName() as String Public Property Get LastName() as String <end of file RoPerson.cls> RoPersons.cls file Public Function Count() as Integer
2
4790
by: Alex Buell | last post by:
Is there an elegant way of converting strings containing digits between different number bases in C++? I.e.: 10 (base 2) = 2 (base 10) FF (base 16) = 256 (base 10) F (base 16) = 1111 (base 2) etc? Thanks, Alex
0
8459
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8367
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8790
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8570
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8650
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7391
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2781
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.