Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Sprintf - źle wyświetla polskie litery
michal_s
post 17.10.2018, 15:39:03
Post #1





Grupa: Zarejestrowani
Postów: 148
Pomógł: 1
Dołączył: 11.12.2010

Ostrzeżenie: (0%)
-----


Cześć. Mam problem z poniższym kodem:

  1. function function_name() {
  2. $time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s <span class="month">%3$s</span><span class="screen-reader-text">%4$s %5$s</span></time>';
  3. if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
  4. $time_string = '<time class="entry-date published" datetime="%1$s">%2$s <span class="month">%3$s</span><span class="screen-reader-text">%4$s %5$s</span></time>';
  5. }
  6.  
  7. $time_string = sprintf( $time_string,
  8. esc_attr( get_the_date( 'c' ) ),
  9. esc_html( get_the_date('j') ),
  10. substr(esc_html( get_the_date('F') ), 0, 3),
  11. substr(esc_html( get_the_date('F') ), 3, 16),
  12. esc_html( get_the_date('Y') )
  13. );
  14. echo '<p class="post-date"><span class="posted-on-text screen-reader-text">' . esc_html_x( 'Posted on', 'post date text', 'pad2' ) . '</span> <span class="posted-on">' . $time_string . '</span></p>';
  15. }


Zwraca on nazwy miesięcy i inne rzeczy. Problem jest np z takim miesiącem jak Październik. W tym wypadku PHP zwraca 'Pa�' zamiast 'Paź' .
Macie pomysł jak rozwiązać ten problem z kodowaniem? Jak to lepiej zrobić...?
Dzięki!
Go to the top of the page
+Quote Post
nospor
post 17.10.2018, 15:43:27
Post #2





Grupa: Moderatorzy
Postów: 36 440
Pomógł: 6290
Dołączył: 27.12.2004




Czyli sugerujesz, ze jak nie uzyjesz sprintf to bedzie ci juz wyswietlal poprawnie?


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
trueblue
post 17.10.2018, 15:51:58
Post #3





Grupa: Zarejestrowani
Postów: 6 761
Pomógł: 1822
Dołączył: 11.03.2014

Ostrzeżenie: (0%)
-----


mb_substr zamiast substr?
http://php.net/manual/en/function.mb-substr.php


--------------------
Go to the top of the page
+Quote Post
michal_s
post 17.10.2018, 16:00:58
Post #4





Grupa: Zarejestrowani
Postów: 148
Pomógł: 1
Dołączył: 11.12.2010

Ostrzeżenie: (0%)
-----


Cytat(trueblue @ 17.10.2018, 16:51:58 ) *


Dzięki wielkie. O to właśnie chodziło wink.gif
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 28.03.2024 - 20:38