niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » PHP
Hebrew in php
Post new topic   Reply to topic Page 1 of 1 [6 Posts] View previous topic :: View next topic
Author Message
BJY
*nix forums beginner


Joined: 20 Jul 2006
Posts: 2

PostPosted: Thu Jul 20, 2006 1:54 pm    Post subject: Hebrew in php Reply with quote

I can't seem to use PHP code in the start of my hebrew-language pages.

If I do this....
<HTML dir="rtl" lang="he">
<?php include 'header.inc'; ?>
....all is fine.

However, if I do this at the start of the file...
<?php include 'header.inc'; ?>
.... where header.inc includes the opening HTML tag, the resulting
output is left to right.

If I View Source, there are 2 non-viewable characters before the HTML
tag (they appear as ? in textpad, they don't appear at all in notepad).
If i delete these characters and save the file, the output then
appears correct. (RTL).

The .php and .inc files are saved in UTF-8.

This is a simplified version. What I really need is to be able to do
cookies, output buffering, etc. at the start of the script. I also
would like to use SMARTY, but that too does the same thing.

Any ideas????

Thanks in advance!
Back to top
chernyshevsky@hotmail.com
*nix forums Guru


Joined: 09 Mar 2005
Posts: 871

PostPosted: Thu Jul 20, 2006 2:20 pm    Post subject: Re: Hebrew in php Reply with quote

BJY wrote:
Quote:
I can't seem to use PHP code in the start of my hebrew-language pages.

If I do this....
HTML dir="rtl" lang="he"
?php include 'header.inc'; ?
...all is fine.

However, if I do this at the start of the file...
?php include 'header.inc'; ?
... where header.inc includes the opening HTML tag, the resulting
output is left to right.

If I View Source, there are 2 non-viewable characters before the HTML
tag (they appear as ? in textpad, they don't appear at all in notepad).
If i delete these characters and save the file, the output then
appears correct. (RTL).

The .php and .inc files are saved in UTF-8.

This is a simplified version. What I really need is to be able to do
cookies, output buffering, etc. at the start of the script. I also
would like to use SMARTY, but that too does the same thing.

Any ideas????

Thanks in advance!

Looks like your editor is adding a LTR mark at the beginning of the
doc. Because IE treats text outside of <html></htm> as though it's
inside the document body, the character would switch the default
direction back to LTR. Set the dir attribute of <body> instead and it
should work.
Back to top
Benjamin Esham
*nix forums beginner


Joined: 13 Jul 2006
Posts: 7

PostPosted: Thu Jul 20, 2006 2:24 pm    Post subject: Re: Hebrew in php Reply with quote

* BJY:

Quote:
I can't seem to use PHP code in the start of my hebrew-language pages.

If I do this....
HTML dir="rtl" lang="he"
?php include 'header.inc'; ?
...all is fine.

However, if I do this at the start of the file...
?php include 'header.inc'; ?
... where header.inc includes the opening HTML tag, the resulting
output is left to right.

If I View Source, there are 2 non-viewable characters before the HTML tag
(they appear as ? in textpad, they don't appear at all in notepad). If i
delete these characters and save the file, the output then appears
correct. (RTL).

The .php and .inc files are saved in UTF-8.

Can you show us the beginning of header.inc? And possibly a hex dump of the
first line or so? If your file contains a Unicode byte order mark [1],
those are probably the characters messing your file up.

[1] http://en.wikipedia.org/wiki/Byte_Order_Mark

--
Benjamin D. Esham
bdesham@gmail.com | AIM: bdesham128 | Jabber: same as e-mail
WHY DO THEY ALWAYS SEND THE POOR!?
Back to top
BJY
*nix forums beginner


Joined: 20 Jul 2006
Posts: 2

PostPosted: Thu Jul 20, 2006 3:46 pm    Post subject: Re: Hebrew in php Reply with quote

Chung Leong wrote:
Quote:
Set the dir attribute of <body> instead and it should work.
Chung - Thanks, setting the dir on the body tag did solve this specific

rtl problem... But i'm still trying to solve the main problem of these
extraneous characters...

Benjamin Esham wrote:
Quote:
Can you show us the beginning of header.inc? And possibly a hex dump of the
first line or so? If your file contains a Unicode byte order mark [1],
those are probably the characters messing your file up.

The hex dump of the output indeed shows 'junk' which i don't know where
it comes from:
EF BB BF EF BB BF EF BB BF 3C 48 54 4D 4C
.... where the 3C indicates the start of the <HTML tag

Any idea what makes PHP spit out this at the start of output?


The header.inc is pretty straight-forward:
<HTML dir="rtl" lang="he">
<TITLE>Burritos - בוריטוס - מסעדה מקסיקנית</TITLE>
<script language="javascript" src="burritos.js"></script>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<HEAD>
<style>
<?php include 'burritos.css'; ?>
</style>
..... and then more html

Thanks again!
Back to top
Benjamin Esham
*nix forums beginner


Joined: 13 Jul 2006
Posts: 7

PostPosted: Thu Jul 20, 2006 6:32 pm    Post subject: Re: Hebrew in php Reply with quote

BJY wrote:

Quote:
Benjamin Esham wrote:

Can you show us the beginning of header.inc? And possibly a hex dump of
the first line or so? If your file contains a Unicode byte order mark
[1], those are probably the characters messing your file up.

The hex dump of the output indeed shows 'junk' which i don't know where it
comes from: EF BB BF EF BB BF EF BB BF 3C 48 54 4D 4C ... where the 3C
indicates the start of the <HTML tag

Any idea what makes PHP spit out this at the start of output?

I think I've found your problem. From [1]:

| Quite a lot of Windows software (including Windows Notepad) adds one to
| UTF-8 files. However in Unix-like systems (which make heavy use of text
| files for configuration) this practice is not recommended, as it will
| interfere with correct processing of important codes such as the hash-bang
| at the start of an interpreted script. It may also interfere with source
| for programming languages that don't recognise it. For example, [...] in
| PHP, if output buffering is disabled, it has the subtle effect of causing
| the page to start being sent to the browser, preventing custom headers
| from being specified by the PHP script. The UTF-8 representation of the
| BOM is the byte sequence EF BB BF.

It looks like the phantom "EF BB BF" bytes are Unicode BOMs. (Why there are
three of them I have no idea.)

Are you using Notepad? If so, I recommend you use a different editor; if
not, see if there's an option to turn off the inclusion of the BOM. If
you're looking for a new editor, I recommend Vim [2], which has great
support for bidirectional text editing, although it does have a rather steep
learning curve. You might check out the comp.editors group if you have any
further questions about text editing and editors.

[1] http://en.wikipedia.org/wiki/Byte_Order_Mark
[2] http://www.vim.org

HTH!
--
Benjamin D. Esham
bdesham@gmail.com | AIM: bdesham128 | Jabber: same as e-mail
"Whenever a theory appears to you as the only possible one, take
this as a sign that you have neither understood the theory nor
the problem which it was intended to solve." — Karl Popper
Back to top
Markus Ernst
*nix forums addict


Joined: 22 Feb 2005
Posts: 61

PostPosted: Thu Jul 20, 2006 7:05 pm    Post subject: Re: Hebrew in php Reply with quote

BJY schrieb:
Quote:
The header.inc is pretty straight-forward:
HTML dir="rtl" lang="he"
TITLE>Burritos - בוריטוס - מסעדה מקסיקנית</TITLE
script language="javascript" src="burritos.js"></script
meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" /

BTW I assume that the charset should rather say utf-8.

--
Markus
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [6 Posts] View previous topic :: View next topic
The time now is Mon Dec 01, 2008 8:26 pm | All times are GMT
navigation Forum index » Programming » PHP
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Hebrew Calendar conversions? Shmuel (Seymour J.) Metz modules 4 Fri Apr 21, 2006 6:05 pm
No new posts How to support Hebrew characters for filenames? almubarmij@gmail.com Slackware 4 Fri Dec 16, 2005 11:14 am
No new posts unicode (hebrew) regexp search for new line headaches mitchell_laks Perl 10 Mon Dec 05, 2005 6:46 am
No new posts Bug#340631: ITP: culmus-fancy -- Type1 Fancy Hebrew Fonts... Lior Kaplan devel 2 Thu Nov 24, 2005 6:41 pm
No new posts Bug#338083: ITP: sword-strongs-hebrew -- Strong's Hebrew ... Roberto Sanchez devel 0 Tue Nov 08, 2005 2:20 am

Loan | Babb Fest | Property for sale in Spain | Credit Cards | McDonalds
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2406s ][ Queries: 16 (0.1206s) ][ GZIP on - Debug on ]