Viewed   108 times

I have a PHP script called :

http://cyber-flick.com/apiMorpho.php?method=getMorphoData&word=kot

That displays some data in plain text:

CzÄ???Ä? mowy: rzeczownik
Przypadek: dope??niacz
Rodzaj: ??e??ski
Liczba: mnoga

As you can see in place of proper chars there are so "bushes". What i would like to do is display this in a way so that people see in browser proper UTF-8 characters.

You can encapsulate it in HMTL tags and set in meta UTF-8 encoding, but because the data received from this script will be processed further I don't want to use any HTML tags, it should be only plain text result set.

So is there a way to inform browser that this file is UTF-8 without using meta tags?

PS. File is encoded in UTF-8 and if I manually change charset encoding in my browser to UTF-8 it displays ok, but what I want to acomplish is people to not be required to do so.

 Answers

5
header('Content-type: text/plain; charset=utf-8');
Monday, October 31, 2022
3

Solution: after $description_dom = new DOMDocument(); , i placed this code.

$description_html = mb_convert_encoding($description_node, 'HTML-ENTITIES', "UTF-8");

Simply converts html entities to UTF-8. Instead of

$description_dom->loadHTML( (string)$description_node );

now i load the converted html

$description_dom->loadHTML( (string)$description_html );
Tuesday, September 27, 2022
 
1

try this for the software #2

iconv("UTF-8", "CP437", $this->_output);

Extended ASCII is not the same as plain ASCII. The first one maybe accepts ASCII, but the second software requires Extended ASCII - Codepage 437

see this link

Wednesday, December 7, 2022
 
shades
 
4

Well to solve my problem I added this to my configuration maven binary filtering:

<nonFilteredFileExtensions>                            
    <nonFilteredFileExtension>dcm</nonFilteredFileExtension>
</nonFilteredFileExtensions>
Tuesday, December 6, 2022
 
3

You can try:

add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")

By default, Visual Studio detects a byte-order mark to determine if the source file is in an encoded Unicode format, for example, UTF-16 or UTF-8. If no byte-order mark is found, it assumes the source file is encoded using the current user code page, unless you have specified a code page by using /utf-8 or the /source-charset option.

References

  • Docs - Visual C++ - ‎Documentation - IDE and Tools - Building - Build Reference: /utf-8 (Set Source and Executable character sets to UTF-8)
Monday, December 19, 2022
 
brian_b
 
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :