How to avoid echoing character 65279 in php?
To conclude, and specify the solution:
Windows Notepad adds the BOM character (the 3 bytes: EF BB BF) to files saved with utf-8 encoding.
PHP doesn't seem to be bothered by it - unless you include one php file into another -
then things get messy and strings gets displayed with character(65279) prepended to them.
You can edit the file with another text editor such as Notepad++ and use the encoding
"Encode in UTF-8 without BOM",
and this seems to fix the problem.
Also, you can save the other php file with ANSI encoding in notepad - and this also seem to work (that is, in case you actually don't use any extended characters in the file, I guess...)
Unexpected character ('?' (code 65279 / 0xfeff)) json_encode PHP
Apparently is that I just needed to encode my .php file with UTF-8 without BOM.
How to highlight invisible unicode character 65279; in Visual Studio Code?
How it's work
1) I add extension Gremlins
2) and in C:\Users\tomnolane.vscode\extensions\nhoizey.gremlins-0.6.2\extension.js add this code:
const gremlins = [
{
...
},
{
char: 'feff',
regex: /\ufeff+/g,
width: 0,
message: 'Zero Width No-Break Space',
backgroundColor: 'rgba(255,127,80,.5)',
overviewRulerColor: 'rgba(255,127,80,1)',
},
{
char: '2060',
regex: /\u2060+/g,
width: 0,
message: 'Word Joiner',
backgroundColor: 'rgba(255,127,80,.5)',
overviewRulerColor: 'rgba(255,127,80,1)',
},
{
char: 'fffe',
regex: /\ufffe+/g,
width: 0,
message: 'Not a Character',
backgroundColor: 'rgba(255,127,80,.5)',
overviewRulerColor: 'rgba(255,127,80,1)',
},
]
3) then, reload Visual Studio Code and it's work!
PHP returns html entity on print functions
This entity represents the BOM (Byte Order Mark, Unicode name "ZERO WIDTH NO-BREAK SPACE"). However,
- it should be at the very beginning of the file;
- it shouldn't be escaped as an HTML entity, but written as a plain character.
So something is clearly going wrong when encoding your file.
The character sequence "" is what the BOM looks like when it is encoded with UTF-8, but erroneously interpreted as Latin-1.
This might help you understand the problem.
In order to help you fix this, you need to provide more details/context on what exactly you are doing. For example, where/how do specify the encoding of the output file?
Mysteriously added quotation mark inside a string
I've found the solution:
private readonly string BYTE_ORDER_MARK_UTF8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
...
if (line.StartsWith(BYTE_ORDER_MARK_UTF8))
line = line.Remove(0, BYTE_ORDER_MARK_UTF8.Length);
That was bizzare...
appearing in textarea elements but not in string
Character entities and HTML escaped characters like
and
appearing in HTML source code are converted by the HTML parser into unicode characters like \u00a0
and \ufeff
before being inserted into the DOM.
If replacing them in JavaScript, use their unicode characters, not HTML escape sequences, to match them in DOM strings. For example:
p.textContent = p.textContent.replaceAll("\ufeff", '*'); // zwj
p.textContent = p.textContent.replaceAll("\xa0", '-'); // nbsp
<p id="p"> </p>
Related Topics
How to Bind Parameters via Odbc C#
Sqlconnection SQLcommand SQLdatareader Idisposable
Capture Multiple Key Downs in C#
Uploading Objects to Google Cloud Storage Buckets in C#
JSON.Net - Serialize Property Name Without Quotes
What Are Some Reasons Networkstream.Read Would Hang/Block
Register a Dll into the Gac - But Then It Doesn't Show Up in the Assembly Window
Is There a Bigfloat Class in C#
Ews - Access All Shared Calendars
Overloading Getter and Setter Causes a Stack Overflow in C#
Difference Between "Var" and "Object" in C#
File Getting Copied to Syswow64 Instead of System32
Callbackoncollecteddelegate in Globalkeyboardhook Was Detected
Help with a Oledb Connection String for Excel Files
How to Get the Actual Monitor Name? as Seen in the Resolution Dialog
How to Access a Specific Item in a Listbox with Datatemplate