Iam not sure if this is the right place to ask this question.

I have a requirement to replace some text in a PRUint8* with another
String?

void replaceString(const PRUint8* aString, aLength)
{
    nsAutoString content,toReplace;
    toReplace.AppendLiteral("Tokyo");
    NS_NAMED_LITERAL_STRING(pattern, "City");
    CopyASCIItoUTF16(nsDependentCString(reinterpret_cast<const
char*>(aString),aLength), content);
    if (content.Find(pattern) != kNotFound)
    {
        content.ReplaceSubstring(pattern.get(), toReplace.get());
    }
  const char* str = NS_ConvertUTF16toUTF8(content);
  const_cast<PRUint8 *>(aString);
  aString = (PRUint8*)str;
  aLength=strlen(str);


But my final content in some places appear garbled and if replace a
shorter string then it crashes.

Is this the right way to do what I intend to do?.String are really
complex in gecko code.

Thanks in Advance,
Krithi


regards,
Krithi
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout

Reply via email to