Tags:
create new tag
view all tags

Question

I installed TWiki local and set i18N, but looks like not work well. Most of Chinese Characters display normally(people can read), but some not.

There are different situation:

  1. in the Topic Edit and View page, All Chinese Characters Display Normally
  2. in the Topic Raw View, All Chinese Characters Display Not Normally
  3. in some page, like Recently Changed Topics, Not All Chinese Characters Display Normally

I have tried to set other value at {Site}{Locale}, like zh_CN.UTF-8, zh_CN.gb2312, EUC-CN...But not complete work.

But there is some TWiki site which used Chinese well, like this, http://www.pgsqldb.org/

NotCompletelyShowChineseCharacter_Topics_page_02.png

NotCompletelyShowChineseCharacter_Edit_page_02.png

NotCompletelyShowChineseCharacter_Raw_view_page_02.png

NotCompletelyShowChineseCharacter_Recently_changed_topics_page_02.png

Environment

TWiki version: TWiki-4.0.5, Tue, 24 Oct 2006, build 11822, Plugin API version 1.1
TWiki plugins: Default
Server OS: FreeBSD 6.1
Web server: Apache22
Perl version: 5.8.8
Client OS: FreeBSD 6.1
Web Browser: FireFox
Categories:  

-- LiuJia - 17 Nov 2006

Answer

ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

Thanks for the screenshots and for uploading the configure output as requested in SupportGuidelines! This makes it a lot easier to help.

You are recommended to set zh_CN.utf8 for Chinese, or whichever locale is available (see locale -a). Sometimes the .utf8 suffix in your locale setting is not the same as what the browser expects, but utf-8 should work - see {Site}{Charset} in configure to override if the browser expects something different from the locale's charset setting (but note that this is only needed in rare cases, normally the locale setting is enough). See http://www.pgsqldb.org/twiki/bin/testenv for an example of this override, at the end of the page - note they are using an earlier version of TWiki so that testenv is used instead of configure, but the principles are the same.

This test page, which links to http://www.pgsqldb.org/twiki/bin/view/Sandbox/另外一个, is a page with Chinese characters in UTF-8 that display OK in both normal view and Raw view. The fact that this doesn't work in 'Raw' mode may be an I18N bug, but it could also be your setup - we would need to do some TWikiDebugging to find out exactly what's going on. Also, this WebChanges page shows Chinese characters in both page contents and page names.

Since the attached .txt file is valid UTF-8, perhaps TWiki is not setting the headers correctly for your locale in some situations. It would be worth installing the Firefox LiveHttpHeaders extension available at http://livehttpheaders.mozdev.org/ so that you can see what character encoding is set by TWiki in the HTTP headers for (1) normal view and (2) raw view. Or just use wget which is probably included in FreeBSD.

Also, it may be worth turning off the "Auto-detect encoding" feature of Firefox under View | Encoding. Testing with another browser, e.g. Opera, would also be useful.

-- RichardDonkin - 23 Nov 2006 %COMMENT{type="

Thanks for replay. It seems to me that the problem was sloved. Here are some details:

Problem1:
There are some 'question with black skin' and 'right arrow' sign replace some Chinese characters in the 'Topic Raw View'
chinese_characters_display_anqun_21.png

Solved1:
Add __CGI::header(-charset=>'utf-8');__after line 254 at TWiki/lib/TWiki/UI/View.pm
chinese_characters_display_anqun_22.png

Changed:

    my $page;
    # Legacy: If the _only_ skin is 'text' it is used like this:
    # http://.../view/Codev/MyTopic?skin=text&contenttype=text/plain&raw=on
    # which shows the topic as plain text; useful for those who want
    # to download plain text for the topic. So when the skin is 'text'
    # we do _not_ want to create a textarea.
    # raw=on&skin=text is deprecated; use raw=text instead.
    if( $raw eq 'text' || $raw eq 'all' || ( $raw && $skin eq 'text' )) {
        # use raw text
        $page = $text;
    } else {
        my @args = ( $session, $webName, $topicName, $meta, $minimalist );

        $session->enterContext( 'header_text' );
        $page = _prepare($start, @args);
        $session->leaveContext( 'header_text' );

        if( $raw ) {
       if ($text) {
         my $p = $session->{prefs};
         CGI::header(-charset=>'utf-8');
         $page .=
      CGI::textarea( -readonly => 'readonly',
                -wrap => 'virtual',
                -rows => $p->getPreferencesValue('EDITBOXHEIGHT'),
                -cols => $p->getPreferencesValue('EDITBOXWIDTH'),
                -style => $p->getPreferencesValue('EDITBOXSTYLE'),
                -default => $text
              );
       } 
chinese_characters_display_anqun_23.png

Problem2:
There is an 'question with black skin' at the end of sentence, follow an Chinese character
chinese_characters_display_anqun_31.png

Solved1:
Del a space between '/' at the line 1301 at TWiki/lib/TWiki/Render.pm
chinese_characters_display_anqun_32.png

Changed:

sub makeTopicSummary {
    my( $this, $theText, $theTopic, $theWeb, $theFlags ) = @_;
    ASSERT($this->isa( 'TWiki::Render')) if DEBUG;
    $theFlags ||= '';

    my $htext = $this->TML2PlainText( $theText, $theWeb, $theTopic, $theFlags);
    $htext =~ s/\n+//g;

    # FIXME I18N: Avoid splitting within multi-byte characters (e.g. EUC-JP
    # encoding) by encoding bytes as Perl UTF-8 characters in Perl 5.8+. 
    # This avoids splitting within a Unicode codepoint (or a UTF-16
    # surrogate pair, which is encoded as a single Perl UTF-8 character),
    # but we ideally need to avoid splitting closely related Unicode codepoints.
    # Specifically, this means Unicode combining character sequences (e.g.
    # letters and accents) - might be better to split on word boundary if
    # possible.

    # limit to n chars
    my $nchar = $theFlags;
    unless( $nchar =~ s/^.*?([0-9]+).*$/$1/ ) {
        $nchar = $TMLTRUNC;
    }
    $nchar = $MINTRUNC if( $nchar < $MINTRUNC );
    $htext =~ s/^(.{$nchar}.*?)($TWiki::regex{mixedAlphaNumRegex}).*$/$1$2 \.\.\./s;

    # newline conversion to permit embedding in TWiki tables
    $htext =~ s/\s+/ /g;

    return $this->protectPlainText( $htext );
}
chinese_characters_display_anqun_33.png

'Topic Raw View' miss some Chinese characters also display at another (testing)site (maybe is a new TWiki version)
links: http://pbx1.astercon.com/
chinese_characters_display_perchinatestingtwiki_41.png

'Question with black skin' sign also display at another site (maybe is TWiki version: 04 Sep 2004 Rev: 1742 )
links: http://www.pgsqldb.org/
chinese_characters_display_pgsqldb_42.png

-- LiuJia - 23 Nov 2006

Topic attachments
I Attachment History Action Size Date Who Comment
Texttxt CharacterTest2.txt r1 manage 0.5 K 2006-11-18 - 00:09 UnknownUser  
PNGpng NotCompletelyShowChineseCharacter_Edit_page_02.png r1 manage 36.8 K 2006-11-17 - 13:58 UnknownUser  
PNGpng NotCompletelyShowChineseCharacter_Raw_view_page_02.png r1 manage 29.7 K 2006-11-17 - 13:59 UnknownUser  
PNGpng NotCompletelyShowChineseCharacter_Recently_changed_topics_page_02.png r1 manage 45.5 K 2006-11-17 - 14:00 UnknownUser  
PNGpng NotCompletelyShowChineseCharacter_Topics_page_02.png r1 manage 54.0 K 2006-11-17 - 14:01 UnknownUser  
PNGpng chinese_characters_display_anqun_21.png r2 r1 manage 28.7 K 2006-11-25 - 14:09 UnknownUser  
PNGpng chinese_characters_display_anqun_22.png r1 manage 46.6 K 2006-11-23 - 16:18 UnknownUser  
PNGpng chinese_characters_display_anqun_23.png r2 r1 manage 25.6 K 2006-11-25 - 14:10 UnknownUser  
PNGpng chinese_characters_display_anqun_31.png r2 r1 manage 32.5 K 2006-11-25 - 14:12 UnknownUser  
PNGpng chinese_characters_display_anqun_32.png r1 manage 29.8 K 2006-11-23 - 16:23 UnknownUser  
PNGpng chinese_characters_display_anqun_33.png r2 r1 manage 29.0 K 2006-11-25 - 14:15 UnknownUser  
PNGpng chinese_characters_display_perchinatestingtwiki_41.png r1 manage 34.7 K 2006-11-23 - 16:20 UnknownUser  
PNGpng chinese_characters_display_pgsqldb_42.png r3 r2 r1 manage 91.9 K 2006-11-25 - 14:17 UnknownUser  
HTMLhtml configure_utf8.html r1 manage 144.0 K 2006-11-17 - 14:03 UnknownUser  
Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2006-11-25 - LiuJia
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.