How to output characters 195 and 192 into HTML UTF8?

172
July 23, 2018, at 3:10 PM

I want to echo a crude directory structure. Using the ascii characters 192 and 195. How can I do this? I just end up with an invalid character � when using chr(192);. I've tried using mb_convert_encoding but that didnt work either. Any solutions?

Answer 1

I assume by "ASCII characters 192 and 195" you mean └ and ├. Well, those aren't "ASCII", since ASCII only includes 128 characters. It's "Extended ASCII" if anything, but the term "Extended ASCII" doesn't mean anything either since ASCII has been extended hundreds of times and it's undefined what extension exactly you mean. This is likely the issue with you trying to convert the encoding, you really have no idea what you're converting from.

The simplest thing would be to use those characters as plain text:

echo '└';
echo '├';

This requires that your text editor supports the characters, that you're saving the file in an encoding that supports the characters (I recommend UTF-8), and that you're serving the file with the appropriate HTTP headers/meta tags denoting it to be the encoding it's in (e.g. UTF-8).

You could also encode the characters as such in PHP string literals:

echo "\xe2\x94\x94";
echo "\xe2\x94\x9c";

That outputs them as UTF-8 and you will still need to care about declaring your file to be UTF-8 encoded in headers/meta tags.

Or you output them as HTML entities:

echo '├';
echo '└';

This doesn't require any special considerations with regards to file encodings, but is only meaningful in an HTML context.

Rent Charter Buses Company
READ ALSO
quickbooks desktop odbc connection string stuck in apache port

quickbooks desktop odbc connection string stuck in apache port

Good Day Guys i'm stuck in apache port every 5th connection in quickbooks desktop

165
Smarty - Wrong template being loaded with force_compile set to false

Smarty - Wrong template being loaded with force_compile set to false

I am building a small intranet site using SmartyThe templates for each page are loaded dynamically at runtime and the template path and filename are pulled from a SQL back end

154
setting up ajax validation response

setting up ajax validation response

My PHP code for a login form [this part located at the very top on my indexphp where I have the login form] looks something like this:

113
How to write a simple .htaccess with two entry points

How to write a simple .htaccess with two entry points

I have problem while trying to use belowhtaccess file to direct my requests

160