henck / henck/rtf-html-php

Is this support chinese unicode?

Open
#22 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
107
Forks
79
PR merge metrics
No merged PRs in 30d

Description

Hi all,

Thanks! It is working perfectly to get the English wordings but it is not working when the RTF contains Chinese characters which are being store in unicode.

Here is my code:
$rtf = '{\rtf1\ansi\ansicpg1252\uc0\deff0{\fonttbl {\f0\fswiss\fcharset0\fprq2 Arial;} {\f1\fnil\fcharset0\fprq2 SimSun;} {\f2\froman\fcharset2\fprq2 Symbol;}} {\colortbl;\red0\green0\blue0;\red255\green255\blue255;} {\stylesheet{\s0\itap0\f0\fs24 [Normal];}{*\cs10\additive Default Paragraph Font;}} {*\generator TX_RTF32 11.0.401.501;} \deftab1134\paperw11907\paperh16443\margl567\margt567\margr567\margb567\pard\itap0\plain\f1\fs20\loch\f1\hich\f1\u20320\u22909\u21527\par }';

$result = $reader->Parse($rtf);
$formatter = new RtfHtml();
$test = $formatter->Format($reader->root);

and it give me this result:
◊u22909◊par

I am expecting to get the result of \u20320\u22909\u21527\ which I can then translated it back to Chinese character.

Is there any one here have similar issue and what is the solution?

Cheers,
Jack

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the supplied RTF with the parser's Parse call and format the resulting root with RtfHtml->Format. Trace how the \u Unicode escapes and \par marker are handled, then verify that Chinese characters are preserved in the formatted output and that the existing English behavior still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, localization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.