Re: not seeing single quotes and double quotes in php. Appear as ? instead.



raj escribió:
I'm using this code to import some a .txt files onto a webpage, but I keep seeing single quotes amd double quotes as question marks.

Here's the code:

<textarea disabled="disabled" name="textarea2" cols="70" rows="7" wrap="virtual"><?php addslashes(include("../license/license.txt")); ?>
</textarea>

I'd say you've written license.txt with some word processor like Microsoft Word and it uses quotes like “foo” and ‘bar’ (rather than "foo" and 'bar'). You must convert the file into whatever charset your site uses (typically ISO-8859-1 or UTF-8, but I can't assure). If you don't have a good text editor that can do it for you, you can use iconv() in PHP. Or simple change the quotes manually.

Also, you must replace < and > with &lt; and &gt; entities. You can use htmlspecialchars() for the task but you can't apply functions to the output of include! You need to fetch the file with a function that returns a string, such as file_get_contents().


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
.



Relevant Pages

  • Re: Lines longer than...
    ... > Some lines are longer than others, and that messes up my print. ... > I can't just load the file in a Word Processor and have it word ... It is OK inside double quotes, ...
    (comp.unix.shell)
  • Re: [AJAX] JS, should read an XML, but dont happen
    ... quotes ' or double quotes ". ... I don't even know how to type those two characters on my keyboard that you used, ... Use a word processor with 'smart quotes' enabled, which I suspect is what happened here. ...
    (comp.lang.javascript)
  • Re: Project editor
    ... The original UNIX operation system came bundled with a programmable "word processor" named vi. ... The words "word processor" is in quotes because vi was a far, far cry from what we think of word processor meaning today. ... I hated it and considered it a God-send when our shop made emacs available to us. ...
    (microsoft.public.vb.general.discussion)
  • Re: Baked chicken and biscuits
    ... hmmm there has not been question marks on other quotes, ... The question marks you see above show up on every post from google ... put rosie in as an exception in my kf for posters from googlegroups. ...
    (rec.food.cooking)
  • Re: loss of word & excel mac9.2
    ... > I typed letters, made calendars, had fun ... Hit apple-F and run a search for "Microsoft Word" (without quotes) on your ...
    (microsoft.public.mac.office.word)