By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,463 Members | 774 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,463 IT Pros & Developers. It's quick & easy.

Charset

P: n/a
Hi, I'm a newbee, also in english.
The thing is that I have a kind of javascript based search engine that
use a .txt as its database, it has several field delimited by tabs.
What I want to do is using the same application to diferents projects. I
just change the look, the datas and I have another beautiful serach
engine.
How I don't know much about javascript, I made a PHP script that builds
a .txt with identical structure to the one I have just explained and
fill it with the datas. But It doesn't work.
I have noticed that the javascript says anywhere something about
"unicode" charset. The PHP script make a entirely new file each time
from a Access database, I do this because I needed to modify some
database content in some fields, and I think that It doesn't use the
same charset that javascript. I belive this because I tested to paste
same records directly from txt formed by PHP script to original txt and
when saving WordPad tell me something about that I'm saving without
format and I am going to loose any format issue. And after this, I could
see throught the serach engine the records pasted in the txt.

I am using WinXP, Nusphere, Dreamweaver, etc, everything in spanish (so
the charset, I think It is ISO LATIN number-015, with Euro, I'm just
guessing)

Thank's a lot for any help.

Borja González
oa*********@yahoo.es

Remove 123 manually.
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Borja Gonzalez <bo***@nccextremadura.org> wrote:
How I don't know much about javascript, I made a PHP script that builds
a .txt with identical structure to the one I have just explained and
fill it with the datas. But It doesn't work.
What doens't work? You can't create the file or you can't reproduce the
required structure of it?

[charsets] I am using WinXP, Nusphere, Dreamweaver, etc, everything in spanish (so
the charset, I think It is ISO LATIN number-015, with Euro, I'm just
guessing)


Take a look at the thread '"smart" quotes in PHP'
(Message-ID: <Xn***************************@24.24.2.166>) which might
give you some hindts on how to convert oce you figure out whtat the
actual encoding is.

--

Daniel Tryba

Jul 17 '05 #2

P: n/a
Hi,
What doens't work? You can't create the file or you can't reproduce the
required structure of it? What it doesn't work is the javascript search engine. I mean, I manage
to build the file
and it looks like the one that i need, but the javascript doesn't read
it.
[charsets]
I am using WinXP, Nusphere, Dreamweaver, etc, everything in spanish (so
the charset, I think It is ISO LATIN number-015, with Euro, I'm just
guessing)


Take a look at the thread '"smart" quotes in PHP'
(Message-ID: <Xn***************************@24.24.2.166>) which might
give you some hindts on how to convert oce you figure out whtat the
actual encoding is.


I have read it but and... correct me I am wrong:
The original database was encoded using unicode, this I have read from
the javasript code:

<object id="db" CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83"
VIEWASTEXT>
<param NAME="DataURL" VALUE="datdb.dll">
<param NAME="UseHeader" VALUE="True">
<param NAME="CharSet" VALUE="unicode">
<param NAME="FieldDelim" VALUE=" ">
</object>

The new database I have built It in not unicode but other encoding
system, so I anyhow have
to convert it:

$fp=fopen("datdb.txt","w");

$cabecera="\"Titulo\"\t\"Descripcion\"\t\"Localida d\"\t\"Seccion\"\t\"Enlaces\"\t\"Correo\"\r\n";
fputs($fp, $cabecera);
$link=mysql_connect("localhost");
mysql_select_db("test",$link);
$query="SELECT Titulo,Autores,Tema,Archivo FROM abstracts";
$resultado=mysql_query($query,$link);
while ($regdb=mysql_fetch_array($resultado, MYSQL_ASSOC)) {
$regtxt="\"<a href=\"\"abstracts/";
$regtxt.=$regdb["Archivo"];
$regtxt.="\"\" class=\"\"rsURL\"\">";
$regtxt.=ereg_replace("\r\n","
",ucfirst(strtolower($regdb["Titulo"])));
$regtxt.="</a>\"";
$regtxt.="\t\"";
$regtxt.=ereg_replace("\r\n"," ",$regdb["Autores"]);
$regtxt.="\"\t\"";
$regtxt.="Badajoz";
$regtxt.="\"\t\"";
$regtxt.="Sesiones, " . $regdb["Tema"];
//$regtxt.="\"\t\"<span></span>\"\t\"<span></span>\"";
$regtxt.="\"\r\n";
fputs($fp, $regtxt);
fclose($fp);
And my question is:
How do I manage that php script write the file encoded in unicode?

Thanks a lot
Borja
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Jul 17 '05 #3

P: n/a
Borja Gonzalez <bo***@nccextremadura.org> wrote:
Take a look at the thread '"smart" quotes in PHP'
(Message-ID: <Xn***************************@24.24.2.166>) which might
give you some hindts on how to convert oce you figure out whtat the
actual encoding is.
I have read it but and... correct me I am wrong:

[snip] The new database I have built It in not unicode but other encoding
system, so I anyhow have
You know which?

[some string] fputs($fp, $regtxt);
fclose($fp);
And my question is:
How do I manage that php script write the file encoded in unicode?


As already mentioned in the thread mentioned above:
1-utf8_encode
2-iconv
3-str_replace

1 is preferable but your data needs to be in iso-8859-1 (if you are
using iso-8859-15 you could translate the generic curreny char to the
EUR manually)

2 is optionally, so your server might lack iconv support

3 if all else fails your last hope.

--

Daniel Tryba

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.