Skip to content

Instantly share code, notes, and snippets.

@yrashk
Created February 7, 2011 04:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yrashk/1e096b658097c19cf309 to your computer and use it in GitHub Desktop.
Save yrashk/1e096b658097c19cf309 to your computer and use it in GitHub Desktop.
std::string LLVivoxVoiceClient::nameFromID(const LLUUID &uuid)
{
std::string result;
if (uuid.isNull()) {
//VIVOX, the uuid emtpy look for the mURIString and return that instead.
//result.assign(uuid.mURIStringName);
LLStringUtil::replaceChar(result, '_', ' ');
return result;
}
// Prepending this apparently prevents conflicts with reserved names inside the vivox code.
result = "x";
// Base64 encode and replace the pieces of base64 that are less compatible
// with e-mail local-parts.
// See RFC-4648 "Base 64 Encoding with URL and Filename Safe Alphabet"
result += LLBase64::encode(uuid.mData, UUID_BYTES);
LLStringUtil::replaceChar(result, '+', '-');
LLStringUtil::replaceChar(result, '/', '_');
// If you need to transform a GUID to this form on the Mac OS X command line, this will do so:
// echo -n x && (echo e669132a-6c43-4ee1-a78d-6c82fff59f32 |xxd -r -p |openssl base64|tr '/+' '_-')
// The reverse transform can be done with:
// echo 'x5mkTKmxDTuGnjWyC__WfMg==' |cut -b 2- -|tr '_-' '/+' |openssl base64 -d|xxd -p
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment