Index: /trunk/include/iprt/mangling.h
===================================================================
--- /trunk/include/iprt/mangling.h	(revision 84295)
+++ /trunk/include/iprt/mangling.h	(revision 84296)
@@ -4078,8 +4078,5 @@
  * Unstable variables (alphabetical order):
  */
-# define g_au8RTBase64CharToVal                         RT_MANGLING(g_au8RTBase64CharToVal)
-# define g_szRTBase64ValToChar                          RT_MANGLING(g_szRTBase64ValToChar)
-# define g_acchRTBase64EolStyles                        RT_MANGLING(g_acchRTBase64EolStyles)
-# define g_aachRTBase64EolStyles                        RT_MANGLING(g_aachRTBase64EolStyles)
+/* none */
 
 #endif /* !DOXYGEN_RUNNING */
Index: /trunk/src/VBox/Runtime/common/string/base64-utf16.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/string/base64-utf16.cpp	(revision 84295)
+++ /trunk/src/VBox/Runtime/common/string/base64-utf16.cpp	(revision 84296)
@@ -49,6 +49,6 @@
 DECL_FORCE_INLINE(uint8_t) rtBase64TranslateUtf16(RTUTF16 wc)
 {
-    if (wc < RT_ELEMENTS(g_au8RTBase64CharToVal))
-        return g_au8RTBase64CharToVal[wc];
+    if (wc < RT_ELEMENTS(g_au8rtBase64CharToVal))
+        return g_au8rtBase64CharToVal[wc];
     if (RTUniCpIsSpace(wc))
         return BASE64_SPACE;
@@ -62,5 +62,5 @@
     if (cwcStringMax > 0)
         return rtBase64TranslateUtf16(*pwszString);
-    return BASE64_INVALID;
+    return BASE64_NULL;
 }
 
@@ -68,5 +68,5 @@
 /*
  * Mostly the same as RTBase64DecodedSizeEx, except for the wider character
- * type and therefore more careful handling of g_szRTBase64ValToChar and additional
+ * type and therefore more careful handling of g_szrtBase64ValToChar and additional
  * space characters.  Fixes must be applied to both copies of the code.
  */
@@ -81,10 +81,8 @@
      */
     uint32_t    c6Bits = 0;
-    uint8_t     u8     = BASE64_INVALID;
-    RTUTF16     wc     = 0;
-
-    while (cwcStringMax > 0 && (wc = *pwszString))
-    {
-        u8 = rtBase64TranslateUtf16(wc);
+    uint8_t     u8;
+
+    while ((u8 = rtBase64TranslateNextUtf16(pwszString, cwcStringMax)) != BASE64_NULL)
+    {
         if (u8 < 64)
             c6Bits++;
@@ -108,7 +106,6 @@
         pwszString++;
         cwcStringMax--;
-        while (cwcStringMax > 0 && (wc = *pwszString))
-        {
-            u8 = rtBase64TranslateUtf16(wc);
+        while ((u8 = rtBase64TranslateNextUtf16(pwszString, cwcStringMax)) != BASE64_NULL)
+        {
             if (u8 != BASE64_SPACE)
             {
@@ -129,7 +126,6 @@
      * Base64 text ends? Return failure.
      */
-    if (    u8 == BASE64_INVALID
-        &&  !ppwszEnd
-        &&  wc)
+    if (   u8 == BASE64_INVALID
+        && !ppwszEnd)
         return -1;
 
@@ -165,5 +161,4 @@
     uint8_t     u8;
     unsigned    c6Bits    = 0;
-    AssertCompile(sizeof(char) == sizeof(uint8_t));
 
     for (;;)
@@ -241,8 +236,6 @@
         pwszString++;
         cwcStringMax--;
-        RTUTF16 wc;
-        while (cwcStringMax > 0 && (wc = *pwszString))
-        {
-            u8 = rtBase64TranslateUtf16(wc);
+        while ((u8 = rtBase64TranslateNextUtf16(pwszString, cwcStringMax)) != BASE64_NULL)
+        {
             if (u8 != BASE64_SPACE)
             {
@@ -262,8 +255,6 @@
      * Base64 text ends? Return failure.
      */
-    if (    u8 == BASE64_INVALID
-        &&  !ppwszEnd
-        &&  cwcStringMax != 0
-        &&  *pwszString != '\0')
+    if (   u8 == BASE64_INVALID
+        && !ppwszEnd)
         return VERR_INVALID_BASE64_ENCODING;
 
@@ -361,7 +352,7 @@
 {
     /* Expand the EOL style flags: */
-    size_t const    cchEol = g_acchRTBase64EolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK];
-    char const      chEol0 = g_aachRTBase64EolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK][0];
-    char const      chEol1 = g_aachRTBase64EolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK][1];
+    size_t const    cchEol = g_acchrtBase64EolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK];
+    char const      chEol0 = g_aachrtBase64EolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK][0];
+    char const      chEol1 = g_aachrtBase64EolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK][1];
     Assert(cchEol == (chEol0 != '\0' ? 1U : 0U) + (chEol1 != '\0' ? 1U : 0U));
 
@@ -382,10 +373,10 @@
         /* encode */
         u8A = pbSrc[0];
-        pwcDst[0] = g_szRTBase64ValToChar[u8A >> 2];
+        pwcDst[0] = g_szrtBase64ValToChar[u8A >> 2];
         u8B = pbSrc[1];
-        pwcDst[1] = g_szRTBase64ValToChar[((u8A << 4) & 0x3f) | (u8B >> 4)];
+        pwcDst[1] = g_szrtBase64ValToChar[((u8A << 4) & 0x3f) | (u8B >> 4)];
         u8C = pbSrc[2];
-        pwcDst[2] = g_szRTBase64ValToChar[((u8B << 2) & 0x3f) | (u8C >> 6)];
-        pwcDst[3] = g_szRTBase64ValToChar[u8C & 0x3f];
+        pwcDst[2] = g_szrtBase64ValToChar[((u8B << 2) & 0x3f) | (u8C >> 6)];
+        pwcDst[3] = g_szrtBase64ValToChar[u8C & 0x3f];
 
         /* advance */
@@ -419,6 +410,6 @@
             case 1:
                 u8A = pbSrc[0];
-                pwcDst[0] = g_szRTBase64ValToChar[u8A >> 2];
-                pwcDst[1] = g_szRTBase64ValToChar[(u8A << 4) & 0x3f];
+                pwcDst[0] = g_szrtBase64ValToChar[u8A >> 2];
+                pwcDst[1] = g_szrtBase64ValToChar[(u8A << 4) & 0x3f];
                 pwcDst[2] = '=';
                 pwcDst[3] = '=';
@@ -426,8 +417,8 @@
             case 2:
                 u8A = pbSrc[0];
-                pwcDst[0] = g_szRTBase64ValToChar[u8A >> 2];
+                pwcDst[0] = g_szrtBase64ValToChar[u8A >> 2];
                 u8B = pbSrc[1];
-                pwcDst[1] = g_szRTBase64ValToChar[((u8A << 4) & 0x3f) | (u8B >> 4)];
-                pwcDst[2] = g_szRTBase64ValToChar[(u8B << 2) & 0x3f];
+                pwcDst[1] = g_szrtBase64ValToChar[((u8A << 4) & 0x3f) | (u8B >> 4)];
+                pwcDst[2] = g_szrtBase64ValToChar[(u8B << 2) & 0x3f];
                 pwcDst[3] = '=';
                 break;
Index: /trunk/src/VBox/Runtime/common/string/base64.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/string/base64.cpp	(revision 84295)
+++ /trunk/src/VBox/Runtime/common/string/base64.cpp	(revision 84296)
@@ -51,7 +51,7 @@
 /** Base64 character to value. (RFC 2045)
  * ASSUMES ASCII / UTF-8. */
-DECL_HIDDEN_CONST(const uint8_t)    g_au8RTBase64CharToVal[256] =
-{
-    0xff, 0xff, 0xff, 0xff,   0xff, 0xff, 0xff, 0xff,   0xff, 0xc0, 0xc0, 0xc0,   0xc0, 0xc0, 0xff, 0xff, /* 0x00..0x0f */
+DECL_HIDDEN_CONST(const uint8_t)    g_au8rtBase64CharToVal[256] =
+{
+    0xfe, 0xff, 0xff, 0xff,   0xff, 0xff, 0xff, 0xff,   0xff, 0xc0, 0xc0, 0xc0,   0xc0, 0xc0, 0xff, 0xff, /* 0x00..0x0f */
     0xff, 0xff, 0xff, 0xff,   0xff, 0xff, 0xff, 0xff,   0xff, 0xff, 0xff, 0xff,   0xff, 0xff, 0xff, 0xff, /* 0x10..0x1f */
     0xc0, 0xff, 0xff, 0xff,   0xff, 0xff, 0xff, 0xff,   0xff, 0xff, 0xff,   62,   0xff, 0xff, 0xff,   63, /* 0x20..0x2f */
@@ -72,8 +72,8 @@
 
 /** Value to Base64 character. (RFC 2045) */
-DECL_HIDDEN_CONST(const char)   g_szRTBase64ValToChar[64+1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+DECL_HIDDEN_CONST(const char)   g_szrtBase64ValToChar[64+1] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
 /** The end-of-line lengths (indexed by style flag value). */
-DECL_HIDDEN_CONST(const size_t) g_acchRTBase64EolStyles[RTBASE64_FLAGS_EOL_STYLE_MASK + 1] =
+DECL_HIDDEN_CONST(const size_t) g_acchrtBase64EolStyles[RTBASE64_FLAGS_EOL_STYLE_MASK + 1] =
 {
     /*[RTBASE64_FLAGS_EOL_NATIVE    ]:*/ RTBASE64_EOL_SIZE,
@@ -84,5 +84,5 @@
 
 /** The end-of-line characters (zero, one or two). */
-DECL_HIDDEN_CONST(const char)   g_aachRTBase64EolStyles[RTBASE64_FLAGS_EOL_STYLE_MASK + 1][2] =
+DECL_HIDDEN_CONST(const char)   g_aachrtBase64EolStyles[RTBASE64_FLAGS_EOL_STYLE_MASK + 1][2] =
 {
     /*[RTBASE64_FLAGS_EOL_NATIVE    ]:*/ { RTBASE64_EOL_SIZE == 1 ? '\n' : '\r', RTBASE64_EOL_SIZE == 1 ? '\0' : '\n', },
@@ -105,12 +105,12 @@
         for (unsigned i = 0; i < 64; i++)
         {
-            unsigned ch = g_szRTBase64ValToChar[i];
+            unsigned ch = g_szrtBase64ValToChar[i];
             Assert(ch);
-            Assert(g_au8RTBase64CharToVal[ch] == i);
+            Assert(g_au8rtBase64CharToVal[ch] == i);
         }
 
         for (unsigned i = 0; i < 256; i++)
         {
-            uint8_t u8 = g_au8RTBase64CharToVal[i];
+            uint8_t u8 = g_au8rtBase64CharToVal[i];
             Assert(   (     u8 == BASE64_INVALID
                        &&   !RT_C_IS_ALNUM(i)
@@ -121,5 +121,7 @@
                        &&   RT_C_IS_SPACE(i))
                    || (     u8 < 64
-                       &&   (unsigned)g_szRTBase64ValToChar[u8] == i));
+                       &&   (unsigned)g_szrtBase64ValToChar[u8] == i)
+                   || (     u8 == BASE64_NULL
+                       &&   i  == 0) );
         }
         ASMAtomicWriteBool(&s_fSane, true);
@@ -127,4 +129,15 @@
 }
 #endif /* RT_STRICT */
+
+
+
+/** Fetched the next character in the string and translates it. */
+DECL_FORCE_INLINE(uint8_t) rtBase64TranslateNext(const char *pszString, size_t cchStringMax)
+{
+    AssertCompile(sizeof(unsigned char) == sizeof(uint8_t));
+    if (cchStringMax > 0)
+        return g_au8rtBase64CharToVal[(unsigned char)*pszString];
+    return BASE64_NULL;
+}
 
 
@@ -143,11 +156,8 @@
      */
     uint32_t    c6Bits = 0;
-    uint8_t     u8     = BASE64_INVALID;
-    unsigned    ch     = 0;
-    AssertCompile(sizeof(char) == sizeof(uint8_t));
-
-    while (cchStringMax > 0 && (ch = *pszString))
-    {
-        u8 = g_au8RTBase64CharToVal[ch];
+    uint8_t     u8;
+
+    while ((u8 = rtBase64TranslateNext(pszString, cchStringMax)) != BASE64_NULL)
+    {
         if (u8 < 64)
             c6Bits++;
@@ -171,7 +181,6 @@
         pszString++;
         cchStringMax--;
-        while (cchStringMax > 0 && (ch = *pszString))
-        {
-            u8 = g_au8RTBase64CharToVal[ch];
+        while ((u8 = rtBase64TranslateNext(pszString, cchStringMax)) != BASE64_NULL)
+        {
             if (u8 != BASE64_SPACE)
             {
@@ -192,7 +201,6 @@
      * Base64 text ends? Return failure.
      */
-    if (    u8 == BASE64_INVALID
-        &&  !ppszEnd
-        &&  ch)
+    if (   u8 == BASE64_INVALID
+        && !ppszEnd)
         return -1;
 
@@ -226,13 +234,11 @@
     uint8_t     u8Trio[3] = { 0, 0, 0 }; /* shuts up gcc */
     uint8_t    *pbData    = (uint8_t *)pvData;
-    unsigned    ch;
     uint8_t     u8;
     unsigned    c6Bits    = 0;
-    AssertCompile(sizeof(char) == sizeof(uint8_t));
 
     for (;;)
     {
         /* The first 6-bit group. */
-        while ((u8 = g_au8RTBase64CharToVal[ch = cchStringMax > 0 ? (uint8_t)*pszString : 0]) == BASE64_SPACE)
+        while ((u8 = rtBase64TranslateNext(pszString, cchStringMax)) == BASE64_SPACE)
             pszString++, cchStringMax--;
         if (u8 >= 64)
@@ -246,5 +252,5 @@
 
         /* The second 6-bit group. */
-        while ((u8 = g_au8RTBase64CharToVal[ch = cchStringMax > 0 ? (uint8_t)*pszString : 0]) == BASE64_SPACE)
+        while ((u8 = rtBase64TranslateNext(pszString, cchStringMax)) == BASE64_SPACE)
             pszString++, cchStringMax--;
         if (u8 >= 64)
@@ -260,5 +266,5 @@
         /* The third 6-bit group. */
         u8 = BASE64_INVALID;
-        while ((u8 = g_au8RTBase64CharToVal[ch = cchStringMax > 0 ? (uint8_t)*pszString : 0]) == BASE64_SPACE)
+        while ((u8 = rtBase64TranslateNext(pszString, cchStringMax)) == BASE64_SPACE)
             pszString++, cchStringMax--;
         if (u8 >= 64)
@@ -274,5 +280,5 @@
         /* The fourth 6-bit group. */
         u8 = BASE64_INVALID;
-        while ((u8 = g_au8RTBase64CharToVal[ch = cchStringMax > 0 ? (uint8_t)*pszString : 0]) == BASE64_SPACE)
+        while ((u8 = rtBase64TranslateNext(pszString, cchStringMax)) == BASE64_SPACE)
             pszString++, cchStringMax--;
         if (u8 >= 64)
@@ -305,7 +311,6 @@
         pszString++;
         cchStringMax--;
-        while (cchStringMax > 0 && (ch = (uint8_t)*pszString))
-        {
-            u8 = g_au8RTBase64CharToVal[ch];
+        while ((u8 = rtBase64TranslateNext(pszString, cchStringMax)) != BASE64_NULL)
+        {
             if (u8 != BASE64_SPACE)
             {
@@ -325,7 +330,6 @@
      * Base64 text ends? Return failure.
      */
-    if (    u8 == BASE64_INVALID
-        &&  !ppszEnd
-        &&  ch != '\0')
+    if (   u8 == BASE64_INVALID
+        && !ppszEnd)
         return VERR_INVALID_BASE64_ENCODING;
 
@@ -402,5 +406,5 @@
 RTDECL(size_t) RTBase64EncodedLengthEx(size_t cbData, uint32_t fFlags)
 {
-    size_t const cchEol = g_acchRTBase64EolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK];
+    size_t const cchEol = g_acchrtBase64EolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK];
 
     if (cbData * 8 / 8 != cbData)
@@ -441,7 +445,7 @@
 {
     /* Expand the EOL style flags: */
-    size_t const    cchEol = g_acchRTBase64EolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK];
-    char const      chEol0 = g_aachRTBase64EolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK][0];
-    char const      chEol1 = g_aachRTBase64EolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK][1];
+    size_t const    cchEol = g_acchrtBase64EolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK];
+    char const      chEol0 = g_aachrtBase64EolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK][0];
+    char const      chEol1 = g_aachrtBase64EolStyles[fFlags & RTBASE64_FLAGS_EOL_STYLE_MASK][1];
     Assert(cchEol == (chEol0 != '\0' ? 1U : 0U) + (chEol1 != '\0' ? 1U : 0U));
 
@@ -462,10 +466,10 @@
         /* encode */
         u8A = pbSrc[0];
-        pchDst[0] = g_szRTBase64ValToChar[u8A >> 2];
+        pchDst[0] = g_szrtBase64ValToChar[u8A >> 2];
         u8B = pbSrc[1];
-        pchDst[1] = g_szRTBase64ValToChar[((u8A << 4) & 0x3f) | (u8B >> 4)];
+        pchDst[1] = g_szrtBase64ValToChar[((u8A << 4) & 0x3f) | (u8B >> 4)];
         u8C = pbSrc[2];
-        pchDst[2] = g_szRTBase64ValToChar[((u8B << 2) & 0x3f) | (u8C >> 6)];
-        pchDst[3] = g_szRTBase64ValToChar[u8C & 0x3f];
+        pchDst[2] = g_szrtBase64ValToChar[((u8B << 2) & 0x3f) | (u8C >> 6)];
+        pchDst[3] = g_szrtBase64ValToChar[u8C & 0x3f];
 
         /* advance */
@@ -499,6 +503,6 @@
             case 1:
                 u8A = pbSrc[0];
-                pchDst[0] = g_szRTBase64ValToChar[u8A >> 2];
-                pchDst[1] = g_szRTBase64ValToChar[(u8A << 4) & 0x3f];
+                pchDst[0] = g_szrtBase64ValToChar[u8A >> 2];
+                pchDst[1] = g_szrtBase64ValToChar[(u8A << 4) & 0x3f];
                 pchDst[2] = '=';
                 pchDst[3] = '=';
@@ -506,8 +510,8 @@
             case 2:
                 u8A = pbSrc[0];
-                pchDst[0] = g_szRTBase64ValToChar[u8A >> 2];
+                pchDst[0] = g_szrtBase64ValToChar[u8A >> 2];
                 u8B = pbSrc[1];
-                pchDst[1] = g_szRTBase64ValToChar[((u8A << 4) & 0x3f) | (u8B >> 4)];
-                pchDst[2] = g_szRTBase64ValToChar[(u8B << 2) & 0x3f];
+                pchDst[1] = g_szrtBase64ValToChar[((u8A << 4) & 0x3f) | (u8B >> 4)];
+                pchDst[2] = g_szrtBase64ValToChar[(u8B << 2) & 0x3f];
                 pchDst[3] = '=';
                 break;
Index: /trunk/src/VBox/Runtime/common/string/base64.h
===================================================================
--- /trunk/src/VBox/Runtime/common/string/base64.h	(revision 84295)
+++ /trunk/src/VBox/Runtime/common/string/base64.h	(revision 84296)
@@ -32,8 +32,9 @@
 #define RTBASE64_LINE_LEN   64
 
-/** @name Special g_au8RTBase64CharToVal values
+/** @name Special g_au8rtBase64CharToVal values
  * @{ */
 #define BASE64_SPACE        0xc0
 #define BASE64_PAD          0xe0
+#define BASE64_NULL         0xfe
 #define BASE64_INVALID      0xff
 /** @} */
@@ -43,8 +44,8 @@
 *   Global Variables                                                                                                             *
 *********************************************************************************************************************************/
-extern DECLHIDDEN(const uint8_t)    g_au8RTBase64CharToVal[256];
-extern DECLHIDDEN(const char)       g_szRTBase64ValToChar[64+1];
-extern DECLHIDDEN(const size_t)     g_acchRTBase64EolStyles[RTBASE64_FLAGS_EOL_STYLE_MASK + 1];
-extern DECLHIDDEN(const char)       g_aachRTBase64EolStyles[RTBASE64_FLAGS_EOL_STYLE_MASK + 1][2];
+extern DECLHIDDEN(const uint8_t)    g_au8rtBase64CharToVal[256];
+extern DECLHIDDEN(const char)       g_szrtBase64ValToChar[64+1];
+extern DECLHIDDEN(const size_t)     g_acchrtBase64EolStyles[RTBASE64_FLAGS_EOL_STYLE_MASK + 1];
+extern DECLHIDDEN(const char)       g_aachrtBase64EolStyles[RTBASE64_FLAGS_EOL_STYLE_MASK + 1][2];
 
 
