1

I have a PHP script that extracts an XML file from a MYSQL. I have the following line:

$xml='<?xml version="1.0" encoding="UTF-16"?>;

But the extracted file is being recognized as UTF-8 UNIX (LF): enter image description here

I need to have the encoding as UTF-16 and Windows CLRF. What is the correct syntax?

Any help is appreciated.

5
  • is that file stored in mysql or created using a php extension like e.g. simplexml? Commented May 1, 2012 at 18:53
  • 1
    That isn't UTF-16 though, I don't see any null bytes. Are you sure you're encoding it as UTF-16? Commented May 1, 2012 at 18:56
  • @Hajo This is created with PHP code only, no extensions or mysql. Commented May 1, 2012 at 19:30
  • php with utf-16 is not funny, i've already given up on it, sorry ^^ Commented May 1, 2012 at 20:02
  • This is indeed not UTF-16. The header is simply wrong :) Commented May 1, 2012 at 20:26

1 Answer 1

1

add a HTTP header:

header('Content-type: text/xml; charset=utf-16')

I'm not sure if text/xml is the best for you, you should decide it: http://www.petefreitag.com/item/381.cfm

Also, your editor in the screenshot is set to UTF-8

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.