xref: /dokuwiki/inc/parser/metadata.php (revision 39a89382d5e693e2b9c9f4e10d73081d1311aeee)
1*39a89382SEsther Brunner<?php
2*39a89382SEsther Brunner/**
3*39a89382SEsther Brunner * Renderer for metadata
4*39a89382SEsther Brunner *
5*39a89382SEsther Brunner * @author Esther Brunner <wikidesign@gmail.com>
6*39a89382SEsther Brunner */
7*39a89382SEsther Brunner
8*39a89382SEsther Brunnerif(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
9*39a89382SEsther Brunner
10*39a89382SEsther Brunnerif ( !defined('DOKU_LF') ) {
11*39a89382SEsther Brunner    // Some whitespace to help View > Source
12*39a89382SEsther Brunner    define ('DOKU_LF',"\n");
13*39a89382SEsther Brunner}
14*39a89382SEsther Brunner
15*39a89382SEsther Brunnerif ( !defined('DOKU_TAB') ) {
16*39a89382SEsther Brunner    // Some whitespace to help View > Source
17*39a89382SEsther Brunner    define ('DOKU_TAB',"\t");
18*39a89382SEsther Brunner}
19*39a89382SEsther Brunner
20*39a89382SEsther Brunnerrequire_once DOKU_INC . 'inc/parser/renderer.php';
21*39a89382SEsther Brunner
22*39a89382SEsther Brunner/**
23*39a89382SEsther Brunner * The Renderer
24*39a89382SEsther Brunner */
25*39a89382SEsther Brunnerclass Doku_Renderer_metadata extends Doku_Renderer {
26*39a89382SEsther Brunner
27*39a89382SEsther Brunner  var $doc  = '';
28*39a89382SEsther Brunner  var $meta = array();
29*39a89382SEsther Brunner
30*39a89382SEsther Brunner  var $headers = array();
31*39a89382SEsther Brunner  var $capture = true;
32*39a89382SEsther Brunner  var $store   = '';
33*39a89382SEsther Brunner
34*39a89382SEsther Brunner  function meta($data) {
35*39a89382SEsther Brunner    if (is_array($data)){
36*39a89382SEsther Brunner      $this->meta = $data;
37*39a89382SEsther Brunner      if (!$this->meta['title']) $this->meta['title'] = $data['first_heading'];
38*39a89382SEsther Brunner    }
39*39a89382SEsther Brunner  }
40*39a89382SEsther Brunner
41*39a89382SEsther Brunner  function document_start(){
42*39a89382SEsther Brunner    //reset some variables
43*39a89382SEsther Brunner    $this->meta['description']['abstract'] = '';
44*39a89382SEsther Brunner    $this->meta['description']['tableofcontents'] = array();
45*39a89382SEsther Brunner    $this->meta['relation']['haspart'] = array();
46*39a89382SEsther Brunner    $this->meta['relation']['references'] = array();
47*39a89382SEsther Brunner    $this->headers = array();
48*39a89382SEsther Brunner  }
49*39a89382SEsther Brunner
50*39a89382SEsther Brunner  function document_end(){
51*39a89382SEsther Brunner    if (!$this->meta['description']['abstract']){
52*39a89382SEsther Brunner      // cut off too long abstracts
53*39a89382SEsther Brunner      $this->doc = trim($this->doc);
54*39a89382SEsther Brunner      if (strlen($this->doc) > 500)
55*39a89382SEsther Brunner        $this->doc = substr($this->doc, 0, 500).'…';
56*39a89382SEsther Brunner      $this->meta['description']['abstract'] = $this->doc;
57*39a89382SEsther Brunner    }
58*39a89382SEsther Brunner  }
59*39a89382SEsther Brunner
60*39a89382SEsther Brunner  function header($text, $level, $pos) {
61*39a89382SEsther Brunner    global $conf;
62*39a89382SEsther Brunner
63*39a89382SEsther Brunner    // create a unique header id
64*39a89382SEsther Brunner    $hid = $this->_headerToLink($text,'true');
65*39a89382SEsther Brunner
66*39a89382SEsther Brunner    //handle TOC
67*39a89382SEsther Brunner    if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']){
68*39a89382SEsther Brunner      // the TOC is one of our standard ul list arrays ;-)
69*39a89382SEsther Brunner      $this->meta['description']['tableofcontents'][] = array(
70*39a89382SEsther Brunner        'hid'   => $hid,
71*39a89382SEsther Brunner        'title' => $text,
72*39a89382SEsther Brunner        'type'  => 'ul',
73*39a89382SEsther Brunner        'level' => $level-$conf['toptoclevel']+1
74*39a89382SEsther Brunner      );
75*39a89382SEsther Brunner    }
76*39a89382SEsther Brunner
77*39a89382SEsther Brunner    // add to summary
78*39a89382SEsther Brunner    if ($this->capture && ($level > 1)) $this->doc .= DOKU_LF.$text.DOKU_LF;
79*39a89382SEsther Brunner  }
80*39a89382SEsther Brunner
81*39a89382SEsther Brunner  function section_open($level){}
82*39a89382SEsther Brunner  function section_close(){}
83*39a89382SEsther Brunner
84*39a89382SEsther Brunner  function cdata($text){
85*39a89382SEsther Brunner    if ($this->capture) $this->doc .= $text;
86*39a89382SEsther Brunner  }
87*39a89382SEsther Brunner
88*39a89382SEsther Brunner  function p_open(){
89*39a89382SEsther Brunner    if ($this->capture) $this->doc .= DOKU_LF;
90*39a89382SEsther Brunner  }
91*39a89382SEsther Brunner
92*39a89382SEsther Brunner  function p_close(){
93*39a89382SEsther Brunner    if ($this->capture){
94*39a89382SEsther Brunner      if (strlen($this->doc) > 250) $this->capture = false;
95*39a89382SEsther Brunner      else $this->doc .= DOKU_LF;
96*39a89382SEsther Brunner    }
97*39a89382SEsther Brunner  }
98*39a89382SEsther Brunner
99*39a89382SEsther Brunner  function linebreak(){
100*39a89382SEsther Brunner    if ($this->capture) $this->doc .= DOKU_LF;
101*39a89382SEsther Brunner  }
102*39a89382SEsther Brunner
103*39a89382SEsther Brunner  function hr(){
104*39a89382SEsther Brunner    if ($this->capture){
105*39a89382SEsther Brunner      if (strlen($this->doc) > 250) $this->capture = false;
106*39a89382SEsther Brunner      else $this->doc .= DOKU_LF.'----------'.DOKU_LF;
107*39a89382SEsther Brunner    }
108*39a89382SEsther Brunner  }
109*39a89382SEsther Brunner
110*39a89382SEsther Brunner  function strong_open(){}
111*39a89382SEsther Brunner  function strong_close(){}
112*39a89382SEsther Brunner
113*39a89382SEsther Brunner  function emphasis_open(){}
114*39a89382SEsther Brunner  function emphasis_close(){}
115*39a89382SEsther Brunner
116*39a89382SEsther Brunner  function underline_open(){}
117*39a89382SEsther Brunner  function underline_close(){}
118*39a89382SEsther Brunner
119*39a89382SEsther Brunner  function monospace_open(){}
120*39a89382SEsther Brunner  function monospace_close(){}
121*39a89382SEsther Brunner
122*39a89382SEsther Brunner  function subscript_open(){}
123*39a89382SEsther Brunner  function subscript_close(){}
124*39a89382SEsther Brunner
125*39a89382SEsther Brunner  function superscript_open(){}
126*39a89382SEsther Brunner  function superscript_close(){}
127*39a89382SEsther Brunner
128*39a89382SEsther Brunner  function deleted_open(){}
129*39a89382SEsther Brunner  function deleted_close(){}
130*39a89382SEsther Brunner
131*39a89382SEsther Brunner  /**
132*39a89382SEsther Brunner   * Callback for footnote start syntax
133*39a89382SEsther Brunner   *
134*39a89382SEsther Brunner   * All following content will go to the footnote instead of
135*39a89382SEsther Brunner   * the document. To achieve this the previous rendered content
136*39a89382SEsther Brunner   * is moved to $store and $doc is cleared
137*39a89382SEsther Brunner   *
138*39a89382SEsther Brunner   * @author Andreas Gohr <andi@splitbrain.org>
139*39a89382SEsther Brunner   */
140*39a89382SEsther Brunner  function footnote_open() {
141*39a89382SEsther Brunner    if ($this->capture){
142*39a89382SEsther Brunner      // move current content to store and record footnote
143*39a89382SEsther Brunner      $this->store = $this->doc;
144*39a89382SEsther Brunner      $this->doc   = '';
145*39a89382SEsther Brunner    }
146*39a89382SEsther Brunner  }
147*39a89382SEsther Brunner
148*39a89382SEsther Brunner  /**
149*39a89382SEsther Brunner   * Callback for footnote end syntax
150*39a89382SEsther Brunner   *
151*39a89382SEsther Brunner   * All rendered content is moved to the $footnotes array and the old
152*39a89382SEsther Brunner   * content is restored from $store again
153*39a89382SEsther Brunner   *
154*39a89382SEsther Brunner   * @author Andreas Gohr
155*39a89382SEsther Brunner   */
156*39a89382SEsther Brunner  function footnote_close() {
157*39a89382SEsther Brunner    if ($this->capture){
158*39a89382SEsther Brunner      // restore old content
159*39a89382SEsther Brunner      $this->doc = $this->store;
160*39a89382SEsther Brunner      $this->store = '';
161*39a89382SEsther Brunner    }
162*39a89382SEsther Brunner  }
163*39a89382SEsther Brunner
164*39a89382SEsther Brunner  function listu_open(){
165*39a89382SEsther Brunner    if ($this->capture) $this->doc .= DOKU_LF;
166*39a89382SEsther Brunner  }
167*39a89382SEsther Brunner
168*39a89382SEsther Brunner  function listu_close(){
169*39a89382SEsther Brunner    if ($this->capture && (strlen($this->doc) > 250)) $this->capture = false;
170*39a89382SEsther Brunner  }
171*39a89382SEsther Brunner
172*39a89382SEsther Brunner  function listo_open(){
173*39a89382SEsther Brunner    if ($this->capture) $this->doc .= DOKU_LF;
174*39a89382SEsther Brunner  }
175*39a89382SEsther Brunner
176*39a89382SEsther Brunner  function listo_close(){
177*39a89382SEsther Brunner    if ($this->capture && (strlen($this->doc) > 250)) $this->capture = false;
178*39a89382SEsther Brunner  }
179*39a89382SEsther Brunner
180*39a89382SEsther Brunner  function listitem_open($level){
181*39a89382SEsther Brunner    if ($this->capture) $this->doc .= str_repeat(DOKU_TAB, $level).'* ';
182*39a89382SEsther Brunner  }
183*39a89382SEsther Brunner
184*39a89382SEsther Brunner  function listitem_close(){
185*39a89382SEsther Brunner    if ($this->capture) $this->doc .= DOKU_LF;
186*39a89382SEsther Brunner  }
187*39a89382SEsther Brunner
188*39a89382SEsther Brunner  function listcontent_open(){}
189*39a89382SEsther Brunner  function listcontent_close(){}
190*39a89382SEsther Brunner
191*39a89382SEsther Brunner  function unformatted($text){
192*39a89382SEsther Brunner    if ($this->capture) $this->doc .= $text;
193*39a89382SEsther Brunner  }
194*39a89382SEsther Brunner
195*39a89382SEsther Brunner  function php($text){}
196*39a89382SEsther Brunner
197*39a89382SEsther Brunner  function html($text){}
198*39a89382SEsther Brunner
199*39a89382SEsther Brunner  function preformatted($text){
200*39a89382SEsther Brunner    if ($this->capture) $this->doc .= $text;
201*39a89382SEsther Brunner  }
202*39a89382SEsther Brunner
203*39a89382SEsther Brunner  function file($text){
204*39a89382SEsther Brunner    if ($this->capture){
205*39a89382SEsther Brunner      $this->doc .= DOKU_LF.$text;
206*39a89382SEsther Brunner      if (strlen($this->doc) > 250) $this->capture = false;
207*39a89382SEsther Brunner      else $this->doc .= DOKU_LF;
208*39a89382SEsther Brunner    }
209*39a89382SEsther Brunner  }
210*39a89382SEsther Brunner
211*39a89382SEsther Brunner  function quote_open(){
212*39a89382SEsther Brunner    if ($this->capture) $this->doc .= DOKU_LF.DOKU_TAB.'“';
213*39a89382SEsther Brunner  }
214*39a89382SEsther Brunner
215*39a89382SEsther Brunner  function quote_close(){
216*39a89382SEsther Brunner    if ($this->capture){
217*39a89382SEsther Brunner      $this->doc .= '”';
218*39a89382SEsther Brunner      if (strlen($this->doc) > 250) $this->capture = false;
219*39a89382SEsther Brunner      else $this->doc .= DOKU_LF;
220*39a89382SEsther Brunner    }
221*39a89382SEsther Brunner  }
222*39a89382SEsther Brunner
223*39a89382SEsther Brunner  function code($text, $language = NULL){
224*39a89382SEsther Brunner    if ($this->capture){
225*39a89382SEsther Brunner      $this->doc .= DOKU_LF.$text;
226*39a89382SEsther Brunner      if (strlen($this->doc) > 250) $this->capture = false;
227*39a89382SEsther Brunner      else $this->doc .= DOKU_LF;
228*39a89382SEsther Brunner    }
229*39a89382SEsther Brunner  }
230*39a89382SEsther Brunner
231*39a89382SEsther Brunner  function acronym($acronym){
232*39a89382SEsther Brunner    if ($this->capture) $this->doc .= $acronym;
233*39a89382SEsther Brunner  }
234*39a89382SEsther Brunner
235*39a89382SEsther Brunner  function smiley($smiley){
236*39a89382SEsther Brunner    if ($this->capture) $this->doc .= $smiley;
237*39a89382SEsther Brunner  }
238*39a89382SEsther Brunner
239*39a89382SEsther Brunner  function entity($entity){
240*39a89382SEsther Brunner    if ($this->capture) $this->doc .= $entity;
241*39a89382SEsther Brunner  }
242*39a89382SEsther Brunner
243*39a89382SEsther Brunner  function multiplyentity($x, $y){
244*39a89382SEsther Brunner    if ($this->capture) $this->doc .= $x.'×'.$y;
245*39a89382SEsther Brunner  }
246*39a89382SEsther Brunner
247*39a89382SEsther Brunner  function singlequoteopening(){
248*39a89382SEsther Brunner    if ($this->capture) $this->doc .= '‘';
249*39a89382SEsther Brunner  }
250*39a89382SEsther Brunner
251*39a89382SEsther Brunner  function singlequoteclosing(){
252*39a89382SEsther Brunner    if ($this->capture) $this->doc .= '’';
253*39a89382SEsther Brunner  }
254*39a89382SEsther Brunner
255*39a89382SEsther Brunner  function doublequoteopening(){
256*39a89382SEsther Brunner    if ($this->capture) $this->doc .= '“';
257*39a89382SEsther Brunner  }
258*39a89382SEsther Brunner
259*39a89382SEsther Brunner  function doublequoteclosing(){
260*39a89382SEsther Brunner    if ($this->capture) $this->doc .= '”';
261*39a89382SEsther Brunner  }
262*39a89382SEsther Brunner
263*39a89382SEsther Brunner  function camelcaselink($link) {
264*39a89382SEsther Brunner    $this->internallink($link, $link);
265*39a89382SEsther Brunner  }
266*39a89382SEsther Brunner
267*39a89382SEsther Brunner  function locallink($hash, $name = NULL){}
268*39a89382SEsther Brunner
269*39a89382SEsther Brunner  /**
270*39a89382SEsther Brunner   * keep track of internal links in $this->meta['relation']['references']
271*39a89382SEsther Brunner   */
272*39a89382SEsther Brunner  function internallink($id, $name = NULL){
273*39a89382SEsther Brunner    global $ID;
274*39a89382SEsther Brunner
275*39a89382SEsther Brunner    $default = $this->_simpleTitle($id);
276*39a89382SEsther Brunner
277*39a89382SEsther Brunner    // first resolve and clean up the $id
278*39a89382SEsther Brunner    resolve_pageid(getNS($ID), $id, $exists);
279*39a89382SEsther Brunner    list($id, $hash) = split('#', $id, 2);
280*39a89382SEsther Brunner
281*39a89382SEsther Brunner    // set metadata
282*39a89382SEsther Brunner    $this->meta['relation']['references'][$id] = $exists;
283*39a89382SEsther Brunner    // $data = array('relation' => array('isreferencedby' => array($ID => true)));
284*39a89382SEsther Brunner    // p_set_metadata($id, $data);
285*39a89382SEsther Brunner
286*39a89382SEsther Brunner    // add link title to summary
287*39a89382SEsther Brunner    if ($this->capture){
288*39a89382SEsther Brunner      $name = $this->_getLinkTitle($name, $default, $id);
289*39a89382SEsther Brunner      $this->doc .= $name;
290*39a89382SEsther Brunner    }
291*39a89382SEsther Brunner  }
292*39a89382SEsther Brunner
293*39a89382SEsther Brunner  function externallink($url, $name = NULL){
294*39a89382SEsther Brunner    if ($this->capture){
295*39a89382SEsther Brunner      if ($name) $this->doc .= $name;
296*39a89382SEsther Brunner      else $this->doc .= '<'.$url.'>';
297*39a89382SEsther Brunner    }
298*39a89382SEsther Brunner  }
299*39a89382SEsther Brunner
300*39a89382SEsther Brunner  function interwikilink($match, $name = NULL, $wikiName, $wikiUri){
301*39a89382SEsther Brunner    if ($this->capture){
302*39a89382SEsther Brunner      list($wikiUri, $hash) = explode('#', $wikiUri, 2);
303*39a89382SEsther Brunner      $name = $this->_getLinkTitle($name, $wikiName.'>'.$wikiUri);
304*39a89382SEsther Brunner      $this->doc .= $name;
305*39a89382SEsther Brunner    }
306*39a89382SEsther Brunner  }
307*39a89382SEsther Brunner
308*39a89382SEsther Brunner  function windowssharelink($url, $name = NULL){
309*39a89382SEsther Brunner    if ($this->capture){
310*39a89382SEsther Brunner      if ($name) $this->doc .= $name;
311*39a89382SEsther Brunner      else $this->doc .= '<'.$url.'>';
312*39a89382SEsther Brunner    }
313*39a89382SEsther Brunner  }
314*39a89382SEsther Brunner
315*39a89382SEsther Brunner  function emaillink($address, $name = NULL){
316*39a89382SEsther Brunner    if ($this->capture){
317*39a89382SEsther Brunner      if ($name) $this->doc .= $name;
318*39a89382SEsther Brunner      else $this->doc .= '<'.$address.'>';
319*39a89382SEsther Brunner    }
320*39a89382SEsther Brunner  }
321*39a89382SEsther Brunner
322*39a89382SEsther Brunner  function internalmedia($src, $title=NULL, $align=NULL, $width=NULL,
323*39a89382SEsther Brunner                         $height=NULL, $cache=NULL, $linking=NULL){
324*39a89382SEsther Brunner    if ($this->capture && $title) $this->doc .= '['.$title.']';
325*39a89382SEsther Brunner  }
326*39a89382SEsther Brunner
327*39a89382SEsther Brunner  function externalmedia($src, $title=NULL, $align=NULL, $width=NULL,
328*39a89382SEsther Brunner                         $height=NULL, $cache=NULL, $linking=NULL){
329*39a89382SEsther Brunner    if ($this->capture && $title) $this->doc .= '['.$title.']';
330*39a89382SEsther Brunner  }
331*39a89382SEsther Brunner
332*39a89382SEsther Brunner  function rss($url){}
333*39a89382SEsther Brunner
334*39a89382SEsther Brunner  function table_open($maxcols = NULL, $numrows = NULL){}
335*39a89382SEsther Brunner  function table_close(){}
336*39a89382SEsther Brunner
337*39a89382SEsther Brunner  function tablerow_open(){}
338*39a89382SEsther Brunner  function tablerow_close(){}
339*39a89382SEsther Brunner
340*39a89382SEsther Brunner  function tableheader_open($colspan = 1, $align = NULL){}
341*39a89382SEsther Brunner  function tableheader_close(){}
342*39a89382SEsther Brunner
343*39a89382SEsther Brunner  function tablecell_open($colspan = 1, $align = NULL){}
344*39a89382SEsther Brunner  function tablecell_close(){}
345*39a89382SEsther Brunner
346*39a89382SEsther Brunner  //----------------------------------------------------------
347*39a89382SEsther Brunner  // Utils
348*39a89382SEsther Brunner
349*39a89382SEsther Brunner  /**
350*39a89382SEsther Brunner   * Removes any Namespace from the given name but keeps
351*39a89382SEsther Brunner   * casing and special chars
352*39a89382SEsther Brunner   *
353*39a89382SEsther Brunner   * @author Andreas Gohr <andi@splitbrain.org>
354*39a89382SEsther Brunner   */
355*39a89382SEsther Brunner  function _simpleTitle($name){
356*39a89382SEsther Brunner    global $conf;
357*39a89382SEsther Brunner
358*39a89382SEsther Brunner    if($conf['useslash']){
359*39a89382SEsther Brunner        $nssep = '[:;/]';
360*39a89382SEsther Brunner    }else{
361*39a89382SEsther Brunner        $nssep = '[:;]';
362*39a89382SEsther Brunner    }
363*39a89382SEsther Brunner    $name = preg_replace('!.*'.$nssep.'!','',$name);
364*39a89382SEsther Brunner    //if there is a hash we use the ancor name only
365*39a89382SEsther Brunner    $name = preg_replace('!.*#!','',$name);
366*39a89382SEsther Brunner    return $name;
367*39a89382SEsther Brunner  }
368*39a89382SEsther Brunner
369*39a89382SEsther Brunner  /**
370*39a89382SEsther Brunner   * Creates a linkid from a headline
371*39a89382SEsther Brunner   *
372*39a89382SEsther Brunner   * @param string  $title   The headline title
373*39a89382SEsther Brunner   * @param boolean $create  Create a new unique ID?
374*39a89382SEsther Brunner   * @author Andreas Gohr <andi@splitbrain.org>
375*39a89382SEsther Brunner   */
376*39a89382SEsther Brunner  function _headerToLink($title, $create=false) {
377*39a89382SEsther Brunner    $title = str_replace(':','',cleanID($title,true)); //force ASCII
378*39a89382SEsther Brunner    $title = ltrim($title,'0123456789._-');
379*39a89382SEsther Brunner    if(empty($title)) $title='section';
380*39a89382SEsther Brunner
381*39a89382SEsther Brunner    if($create){
382*39a89382SEsther Brunner      // make sure tiles are unique
383*39a89382SEsther Brunner      $num = '';
384*39a89382SEsther Brunner      while(in_array($title.$num,$this->headers)){
385*39a89382SEsther Brunner        ($num) ? $num++ : $num = 1;
386*39a89382SEsther Brunner      }
387*39a89382SEsther Brunner      $title = $title.$num;
388*39a89382SEsther Brunner      $this->headers[] = $title;
389*39a89382SEsther Brunner    }
390*39a89382SEsther Brunner
391*39a89382SEsther Brunner    return $title;
392*39a89382SEsther Brunner  }
393*39a89382SEsther Brunner
394*39a89382SEsther Brunner  /**
395*39a89382SEsther Brunner   * Construct a title and handle images in titles
396*39a89382SEsther Brunner   *
397*39a89382SEsther Brunner   * @author Harry Fuecks <hfuecks@gmail.com>
398*39a89382SEsther Brunner   */
399*39a89382SEsther Brunner  function _getLinkTitle($title, $default, $id=NULL) {
400*39a89382SEsther Brunner    global $conf;
401*39a89382SEsther Brunner
402*39a89382SEsther Brunner    $isImage = FALSE;
403*39a89382SEsther Brunner    if (is_null($title)){
404*39a89382SEsther Brunner      if ($conf['useheading'] && $id){
405*39a89382SEsther Brunner        $heading = p_get_first_heading($id);
406*39a89382SEsther Brunner        if ($heading) return $heading;
407*39a89382SEsther Brunner      }
408*39a89382SEsther Brunner      return $default;
409*39a89382SEsther Brunner    } else if (is_string($title)){
410*39a89382SEsther Brunner      return $title;
411*39a89382SEsther Brunner    } else if (is_array($title)){
412*39a89382SEsther Brunner      return '['.$title.']';
413*39a89382SEsther Brunner    }
414*39a89382SEsther Brunner  }
415*39a89382SEsther Brunner
416*39a89382SEsther Brunner}
417*39a89382SEsther Brunner
418*39a89382SEsther Brunner//Setup VIM: ex: et ts=4 enc=utf-8 :