Re: Subject: Different character sets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Regarding carriage returns showing up - this is simple : Look at any HTML page source.

You will see it is littered with many carriage returns, long areas with many spaces and so on. In HTML, the spaces (more than one) are condensed into one space, and carriage returns are not significant sas they would be in a standard .txt file.

So, you need to convert the /r/n into HTML line breaks, <br />
Luckily, PHP has a function to do this ;-)

Assume your database content is stored in a variable $result, then use
print(nl2br($result));

This will output <br /> where the newlines are within your content.

About character encoding

(1) Input encoding : You need to specify the encoding of your HTML document initially, I suggest using
a meta tag like this :
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">


Then (2) , you need to tell your server that the content being posted is in a certain range of characters. You can do this using the FORM element's accept-charset tag. This list can be multiple charsets, and is comma or space separated

form accept charset="utf-8"

So you might want to read up on this
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/properties/acceptcharset.asp

(3) There is some information on russian forms handling here :
http://koi8.pp.ru/frame.html?/htmlforms.html

(4) MySQL has character set support which varies by version. MySQL 4 has the best native support, other versions may need some character set support to be compiled into the binary. I believe UTF-8 is supported by default, which is usually OK in the european / americas regions.

You need to speak to your ISP or techies about this. Some functions may be affected by the chosen character sets (eg FULLTEXT searches and so on). See more here :

http://www.mysql.com/doc/en/Charset.html


Cheers - Neil Smith.



At 14:03 20/01/2004 +0000, you wrote:
Date: Tue, 20 Jan 2004 14:59:32 +0100
To: php-db@xxxxxxxxxxxxx
From: Christine Clerc <x.clerc@xxxxxxx>
Content-Type: text/plain; charset="us-ascii" ; format="flowed"
Subject: Different character sets

Hi,

My pages collect short texts from different languages through HTML forms. The texts are stored in a MySQL database. Then, they are used in HTML pages.

Problem 1 : the carriage returns don't show back up.
Problem 2 : The character above chr128 are not coded properly (obviously)
Problem 3 : what about other character sets (russian for example)

Thank you for any information on those subjects.

Christine


========================================================
CaptionKit http://www.captionkit.com : Production tools
for accessible subtitled internet media, transcripts
and searchable video. Supports Real Player, Quicktime
and Windows Media Player.

VideoChat with friends online, get Freshly Toasted every
day at http://www.fresh-toast.net : NetMeeting solutions
for a connected world.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux