*aOutBuffer = nsnull;
ConvertUnicharToUCS4(const PRUnichar *aString, PRUint32 aLength,                     FcChar32 **aOutBuffer, PRUint32 *aOutLen){    *aOutBuffer = nsnull;    *aOutLen = 0;    FcChar32 *outBuffer = gFontUCS4Buffer;    // see if we need to allocate a new buffer for this thing    if (aLength > FONT_SPEC_BUFFER_SIZE) {        outBuffer = new FcChar32[aLength];        if (!outBuffer)            return;    }    PRUint32 outLen = 0;    // Walk the passed in string looking for surrogates to convert to    // their full ucs4 representation.    for (PRUint32 i = 0; i < aLength; ++i) {        PRUnichar c = aString[i];        // Optimized for the non-surrogate case        if (IS_NON_SURROGATE(c)) {            outBuffer[outLen] = c;        }        else if (IS_HIGH_SURROGATE(aString[i])) {            if (i + 1 < aLength && IS_LOW_SURROGATE(aString[i+1])) {                outBuffer[outLen] = SURROGATE_TO_UCS4(c, aString[i + 1]);                ++i;            }            else { // Unpaired high surrogate                outBuffer[outLen] = UCS2_REPLACEMENT;            }        }        else if (IS_LOW_SURROGATE(aString[i])) { // Unpaired low surrogate?            outBuffer[outLen] = UCS2_REPLACEMENT;        }        outLen++;    }    *aOutLen = outLen;    *aOutBuffer = outBuffer;}