1

First. Sorry for my english, i'm brazilian..

I need to move from ASP.NET to PHP, and in ASP.Net have this:

public void Write(string str)
{
     byte[] data = Encoding.UTF8.GetBytes(str.ToString());
     output.Write(data, 0, data.Length);
}

and, in PHP I tried this:

function Write($String)
{
     $data = mb_convert_encoding($String, "UTF8", "Unicode");
     return $data;
}

However, it does not return the same message..

I use this in ASP.NET with XML.

EDIT¹: Output is a MemoryStream

Thanks,

3
  • what is your input and what is the expected output? Commented Oct 6, 2013 at 19:10
  • output is: "MemoryStream", i use this with .aspx, look: " GResponse.Write(xml.ToString());" Commented Oct 6, 2013 at 19:55
  • Why are you using Unicode as the $from_encoding parameter? Commented Oct 6, 2013 at 20:53

1 Answer 1

1
// php manual
string mb_convert_encoding ( string $str , string $to_encoding [, mixed $from_encoding = mb_internal_encoding() ] )

Your function no need "Unicode":

function Write($String)
{
     $data = mb_convert_encoding($String, "ISO-8859-1", "UTF-8");
     return $data;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.