nsCOMPtr <nsIEntityConverter> entityConv; res = nsComponentManager::CreateInstance(kEntityConverterCID, NULL, NS_GET_IID(nsIEntityConverter), getter_AddRefs(entityConv));
nsCOMPtr <nsIEntityConverter> entityConv = do_CreateInstance(kEntityConverterCID, &res);;
static void TestEntityConversion(PRUint32 version){  printf("==============================\n");  printf("Start nsIEntityConverter Test \n");  printf("==============================\n");  PRUint32 i;  nsString inString;  PRUnichar uChar;  nsresult res;  inString.Assign(NS_ConvertASCIItoUCS2("\xA0\xA1\xA2\xA3"));  uChar = (PRUnichar) 8364; //euro  inString.Append(&uChar, 1);  uChar = (PRUnichar) 9830; //  inString.Append(&uChar, 1);  nsCOMPtr <nsIEntityConverter> entityConv;  res = nsComponentManager::CreateInstance(kEntityConverterCID, NULL, NS_GET_IID(nsIEntityConverter), getter_AddRefs(entityConv));  if (NS_FAILED(res)) {printf("\tFailed!! return value != NS_OK\n"); return;}  // convert char by char  for (i = 0; i < inString.Length(); i++) {    char *entity = NULL;    res = entityConv->ConvertToEntity(inString[i], version, &entity);    if (NS_SUCCEEDED(res) && NULL != entity) {      printf("%c %s\n", inString[i], entity);      nsMemory::Free(entity);    }  }  // convert at once as a string  PRUnichar *entities;  res = entityConv->ConvertToEntities(inString.get(), version, &entities);  if (NS_SUCCEEDED(res) && NULL != entities) {    for (i = 0; i < nsCRT::strlen(entities); i++) {      printf("%c", (char) entities[i]);      if (';' == (char) entities[i])        printf("\n");    }    nsMemory::Free(entities);  }  printf("==============================\n");  printf("Finish nsIEntityConverter Test \n");  printf("==============================\n\n");}