Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
Replacing text
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
red



Joined: 03 May 2004
Posts: 919
Location: Zabok

PostPosted: 14.02.2005 19:12    Post subject: Replacing text Add user to your forum ignore list Reply with quote

Evo jedne za programere.
Bilo bi lijepo i krasno kad bi imao PHP skriptu koja bi mi ubacivala ABBR tag sa title atributom za riječi koje odredim.

Primjerice, svugdje gdje piše "CSS", da mi je 'omota' sa ABBR-om:

Code:
<abbr title="Cascading Style Sheets">CSS</abbr>


Any links, pointers, scripts? Smile thnx

_________________
Get busy living, or get busy dying.
Back to top
View user's profile Send private message Visit poster's website Twitter profile
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 14.02.2005 20:38    Post subject: Add user to your forum ignore list Reply with quote

pa napiši je Smile

searchaj tekst sa preg_replace()... mislim da bi ovako nešto radilo
Code:
$search = array ("/CSS/",
                 "/XHTML/");

$replace = array ("<abbr title=\"Cascading Style Sheets\">CSS</abbr>",
                  "<abbr title=\"eXtensible HyperText Markup Language\">XHTML</abbr>");

$html = preg_replace($search, $replace, $html);

treba isprobat... vjerojatno sam negdje zbrljao

naravno (ako ovo radi) treba malo sredit gornje regexpe da ne matcha ako su s lijeve ili s desne strane slova
Back to top
View user's profile Send private message Send e-mail Visit poster's website
red



Joined: 03 May 2004
Posts: 919
Location: Zabok

PostPosted: 14.02.2005 21:16    Post subject: Add user to your forum ignore list Reply with quote

OK, našao sam sve potrebno. Thnx mate.

_________________
Get busy living, or get busy dying.
Back to top
View user's profile Send private message Visit poster's website Twitter profile
red



Joined: 03 May 2004
Posts: 919
Location: Zabok

PostPosted: 19.02.2005 00:20    Post subject: Add user to your forum ignore list Reply with quote

More newbie PHP questions, u vezi replacing texta - htio bi zamijeniti naše balkanske znakove sa UTF-8 entitiesima. Znači, ja napišem primjerice Č, a skripta meni to lijepo pretvori u odgovarajući entity. Za ovaj ABBR issue od prije sam našao wordpress plugin, ali ni uz pomoć njega ne uspijevam ništa 'sklepati', to jest preurediti za ovaj problem... Je li preg_replace pravi izbor? Hewp, please.

_________________
Get busy living, or get busy dying.
Back to top
View user's profile Send private message Visit poster's website Twitter profile
carr



Joined: 13 Nov 2003
Posts: 1397
Location: Karlovac

PostPosted: 19.02.2005 00:38    Post subject: Add user to your forum ignore list Reply with quote

red wrote:
More newbie PHP questions, u vezi replacing texta - htio bi zamijeniti naše balkanske znakove sa UTF-8 entitiesima. Znači, ja napišem primjerice Č, a skripta meni to lijepo pretvori u odgovarajući entity. Za ovaj ABBR issue od prije sam našao wordpress plugin, ali ni uz pomoć njega ne uspijevam ništa 'sklepati', to jest preurediti za ovaj problem... Je li preg_replace pravi izbor? Hewp, please.


ne kuzim upises ga gdje? u fajl , u bazu, u input field?
imas u php-u neke funkcije tipa utfencode, utfdecode, pogledaj manual?

_________________
Bolje biti malo lud, nego malo pametan.
Back to top
View user's profile Send private message Visit poster's website
maratz
mi3.crew


Joined: 24 Nov 2003
Posts: 1207
Location: ZAG

PostPosted: 19.02.2005 02:46    Post subject: Add user to your forum ignore list Reply with quote

Pri ispisu ga promjeniš, probaj nešto kao (pišem napamet):
Code:
<?php
function zamjeni_hr_znakove($tekst){
if (!$tekst) return;
$trazi = array('č', 'ć');
$zamjena = array('&#269;', '&#263;');
$promjenjeno = str_replace($trazi, $zamjena, $tekst);
return $promjenjeno;
}
// ispis:
echo zamjeni_hr_znakove('Tekst sa č i ć');
?>

_________________
STOP HITTING YOURSELF! | NETIQUETTE | TYPETESTER | Hypertext rulez™ | CREATIVE NIGHTS | ACCOMMODATIONS
Back to top
View user's profile Send private message Visit poster's website Twitter profile
red



Joined: 03 May 2004
Posts: 919
Location: Zabok

PostPosted: 19.02.2005 10:37    Post subject: Add user to your forum ignore list Reply with quote

@carr: ni baza, ni field, nego cijela stranica. Npr. upišem neki tekst u svoj index.php, pun balkanskih znakova, a skripta mi ih kad cijelu stvar pokrenem u brauzeru zamijeni sa odgovarajućim entitiesima.

@maratz: sa preg_replace sam napravio sličnu stvar, znači, uspio zamijeniti znakove iz stringa... Ja bi zamijenio sve znakove unutar BODY-ja. Confused

_________________
Get busy living, or get busy dying.
Back to top
View user's profile Send private message Visit poster's website Twitter profile
gog



Joined: 18 Jun 2004
Posts: 679
Location: zagreb

PostPosted: 19.02.2005 12:13    Post subject: Add user to your forum ignore list Reply with quote

red wrote:
@carr: ni baza, ni field, nego cijela stranica. Npr. upišem neki tekst u svoj index.php, pun balkanskih znakova, a skripta mi ih kad cijelu stvar pokrenem u brauzeru zamijeni sa odgovarajućim entitiesima.


Zakaj jednostavno ne uneseš utf-8 znakove, ond možeš preskočiti ovaj korak...
Back to top
View user's profile Send private message Visit poster's website
red



Joined: 03 May 2004
Posts: 919
Location: Zabok

PostPosted: 19.02.2005 12:21    Post subject: Add user to your forum ignore list Reply with quote

gog wrote:
red wrote:
@carr: ni baza, ni field, nego cijela stranica. Npr. upišem neki tekst u svoj index.php, pun balkanskih znakova, a skripta mi ih kad cijelu stvar pokrenem u brauzeru zamijeni sa odgovarajućim entitiesima.


Zakaj jednostavno ne uneseš utf-8 znakove, ond možeš preskočiti ovaj korak...


Jer mi je problem stalno pisat entitije umjesto š, č i ostalih.

_________________
Get busy living, or get busy dying.
Back to top
View user's profile Send private message Visit poster's website Twitter profile
maratz
mi3.crew


Joined: 24 Nov 2003
Posts: 1207
Location: ZAG

PostPosted: 19.02.2005 13:31    Post subject: Add user to your forum ignore list Reply with quote

Za statičke dijelove si složi neki makro u text-editoru, a za output iz baze koristi preg_replace ili vateva

Last edited by maratz on 19.02.2005 13:57; edited 1 time in total

_________________
STOP HITTING YOURSELF! | NETIQUETTE | TYPETESTER | Hypertext rulez™ | CREATIVE NIGHTS | ACCOMMODATIONS
Back to top
View user's profile Send private message Visit poster's website Twitter profile
red



Joined: 03 May 2004
Posts: 919
Location: Zabok

PostPosted: 19.02.2005 13:34    Post subject: Add user to your forum ignore list Reply with quote

maratz wrote:
Za statičke dijelove si složi neki makro u text-editoru, a za output iz baze koristi preg_replace ili vateva


OK, thnx.

_________________
Get busy living, or get busy dying.
Back to top
View user's profile Send private message Visit poster's website Twitter profile
gog



Joined: 18 Jun 2004
Posts: 679
Location: zagreb

PostPosted: 19.02.2005 16:36    Post subject: Add user to your forum ignore list Reply with quote

red wrote:

Jer mi je problem stalno pisat entitije umjesto š, č i ostalih.


Pa zašto bi pisao entitije, napiši dijakritički znak po utf-8 standardu i riješeno, ne vidim u čemu je problem...
Back to top
View user's profile Send private message Visit poster's website
red



Joined: 03 May 2004
Posts: 919
Location: Zabok

PostPosted: 19.02.2005 16:52    Post subject: Add user to your forum ignore list Reply with quote

@gog: zbog kompatibilnosti.

_________________
Get busy living, or get busy dying.
Back to top
View user's profile Send private message Visit poster's website Twitter profile
gog



Joined: 18 Jun 2004
Posts: 679
Location: zagreb

PostPosted: 19.02.2005 21:40    Post subject: Add user to your forum ignore list Reply with quote

hmmm, kompatibilnosti s čim?
Back to top
View user's profile Send private message Visit poster's website
red



Joined: 03 May 2004
Posts: 919
Location: Zabok

PostPosted: 20.02.2005 01:56    Post subject: Add user to your forum ignore list Reply with quote

gog wrote:
hmmm, kompatibilnosti s čim?


S browserima, naravno Smile

_________________
Get busy living, or get busy dying.
Back to top
View user's profile Send private message Visit poster's website Twitter profile
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 20.02.2005 19:05    Post subject: Add user to your forum ignore list Reply with quote

Red, ako netko želi u svom browseru vidjeti hrvatska slova, neće ići naokolo i kucati po kućama sa zamolbom da ljudi umjesto slova pišu HTML entity-e nego će instalirati browser/softwer/OS koji može prikazati hrvatska slova (danas čitaj: podrška za unicode).

Mislim, i ja se brinem za usability, ali nemoj se toliko podređivati... tvoj jezik je tvoj jezik, imaš dva dobra encodinga na raspolaganju i to je dovoljno
Back to top
View user's profile Send private message Send e-mail Visit poster's website
carr



Joined: 13 Nov 2003
Posts: 1397
Location: Karlovac

PostPosted: 20.02.2005 20:42    Post subject: Add user to your forum ignore list Reply with quote

red wrote:
gog wrote:
hmmm, kompatibilnosti s čim?


S browserima, naravno Smile


ja ne kuzim u cem je problem?
ja ak ocu da mi se vide ČŽĆŠĐ u unicodeu, u dreamweaveru odem na page properties (ili tako nesto, neznam napamet) i tamo imam encoding koji roknem na unicode.

i sva slova na stranici mi se pretvore u unicode.

sad me zanima, s cim to nije kompatibilno, gledao sam u IE-u, Mozilli i Operi i svugdje radi ko beba.

_________________
Bolje biti malo lud, nego malo pametan.
Back to top
View user's profile Send private message Visit poster's website
red



Joined: 03 May 2004
Posts: 919
Location: Zabok

PostPosted: 20.02.2005 20:53    Post subject: Add user to your forum ignore list Reply with quote

Eh, sad, DW neam, al pretpostavljam da ti on ubaci entity. Ajd pogledaj, baš me zanima.

U vezi kompatibilnosti, tako je, kolko sam imao prilike pročitati, najbolje za (stare) browsere.

_________________
Get busy living, or get busy dying.
Back to top
View user's profile Send private message Visit poster's website Twitter profile
sime
Guest





PostPosted: 20.02.2005 21:21    Post subject: Reply with quote

red wrote:
Eh, sad, DW neam, al pretpostavljam da ti on ubaci entity. Ajd pogledaj, baš me zanima.

U vezi kompatibilnosti, tako je, kolko sam imao prilike pročitati, najbolje za (stare) browsere.


Koliko sam vidia na siteu, koristis Programmers Notepad, koji ne podržava utf-8 encoding IIRC. Vezija 2 (beta) podržava, doduše bugovito)... Da nije u tome problem? Imaš masu malih text editora koji podržavaju. Probaj Notepad2.

Mislim, stvarno nema smisla ovako se jebavati sa entityima...
Back to top
red



Joined: 03 May 2004
Posts: 919
Location: Zabok

PostPosted: 20.02.2005 21:25    Post subject: Add user to your forum ignore list Reply with quote

@Šime: nisam niti mislio na PNotepad... Samo sam mislio to skriptom riješiti Smile

_________________
Get busy living, or get busy dying.
Back to top
View user's profile Send private message Visit poster's website Twitter profile
bj__



Joined: 09 Nov 2004
Posts: 65
Location: Karlovac

PostPosted: 21.02.2005 00:25    Post subject: Add user to your forum ignore list Reply with quote

cek, sad mi nis vise nije jasno... imam editor koji podrzava utf-8 i pisem tekst sa hr slovima i spremim to kao utf-8... na samoj stranici stavim da koristi utf-8 encoding... i zasto to sad ne bi radilo i u kojim browserima? (primjeri, linkovi...)
(zato jer meni to normalno radi u FF-u, IE)
Back to top
View user's profile Send private message Twitter profile
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 21.02.2005 00:45    Post subject: Add user to your forum ignore list Reply with quote

bj___,

Red je već spomenuo stare browsere -- to je i istina.

Misliš da su svi podržali utf-8 odmah čim je došao? Čak se i danas podrška još negdje klima. Ali vraćanje na entity-e nije rješenje nego ljude treba natjerati da idu ukorak sa vremenom. Unicode standard treba implementirati što šire (isto kao i CSS 2 i 3 među browserima), a mi smo odgovorni da ih koristimo kako bi do toga i došlo. Znači, naša developerska dužnost je da prihvaćamo i koristimo nove tehnologije/standarde ali istovremeno zadržavamo određen backward compatibility (eg. css hackovi za IE5.x) jer ljudi koji to nisu (eg. Joe Idiot) u prihvaćanju tehnologija zaostaju za nama developerima. No, nekorištenje novih predivnih tehnologija kao što su utf ili css ili xml je svetogrđe -- prihvatite ih i time povucite druge za sobom Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gog



Joined: 18 Jun 2004
Posts: 679
Location: zagreb

PostPosted: 21.02.2005 01:50    Post subject: Add user to your forum ignore list Reply with quote

red wrote:
Eh, sad, DW neam, al pretpostavljam da ti on ubaci entity. Ajd pogledaj, baš me zanima.


Ne ubaci entity. utf-8 se vidi u ie 5.0, niže od toga mi ionako ništa ne znači...
Back to top
View user's profile Send private message Visit poster's website
kelso



Joined: 19 Jul 2004
Posts: 507
Location: Zagreb -> Zapruđe

PostPosted: 21.02.2005 13:10    Post subject: Add user to your forum ignore list Reply with quote

Jel ovo možda ono što vi tražite?

Tu je PHP skripta

Rolling Eyes
Back to top
View user's profile Send private message Send e-mail MSN Messenger
sime
Guest





PostPosted: 21.02.2005 14:02    Post subject: Reply with quote

kelso wrote:
Jel ovo možda ono što vi tražite?

Tu je PHP skripta

Rolling Eyes

Nope Smile
Back to top
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group