if (aSource) { AppendUTF16toUTF8(nsDependentString(aSource), aDest); }
nsAString::const_iterator source_start, source_end; CalculateUTF8Size calculator; copy_string(aSource.BeginReading(source_start), aSource.EndReading(source_end), calculator);  PRUint32 count = calculator.Size();  if (count) { PRUint32 old_dest_length = aDest.Length();   aDest.SetLength(old_dest_length + count);  nsACString::iterator dest; aDest.BeginWriting(dest);  dest.advance(old_dest_length);  if (count <= (PRUint32)dest.size_forward()) {       ConvertUTF16toUTF8 converter(dest.get()); copy_string(aSource.BeginReading(source_start), aSource.EndReading(source_end), converter);  if (converter.Size() != count) { NS_ERROR("Input invalid or incorrect length was calculated");  aDest.SetLength(old_dest_length); } } else {      aDest.Replace(old_dest_length, count, NS_ConvertUTF16toUTF8(aSource)); } }
AppendUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest )  {    if (aSource) {      AppendUTF16toUTF8(nsDependentString(aSource), aDest);    }  }