android rtf转html,将RTF格式的文件转成HTML并在网页中显示的代码

";

}

// Replace tab with alternating spaces

// and nonbreakingwhitespaces.

if(ereg("\(tab)", $tags)) { $html .= ""; }

return $html;

}

function ProcessWord($word) {

// Replace \ with

$word = ereg_replace("[\]{2,}", "\", $word);

// Replace { with {

$word = ereg_replace("[\][{]", "{", $word);

// Replace } with }

$word = ereg_replace("[\][}]", "}", $word);

// Replace 2 spaces with one space.

$word = ereg_replace(" ", "", $word);

return $word;

}

$color = "000000";

$size = 1;

$bullets = 0;

// Read the uploaded file into an array.

//

$rtfile = file($userfile);

$fileLength = count($rtfile);

// Loop through the rest of the array

for($i = 1; $i < $fileLength; $i ) {

/*

** If the line contains "colortbl" then we found the color table.

** We'll have to split it up into each individual red, green, and blue

** Convert it to hex and then put the red, green, and blue back together.

** Then store each into an array called fcolor.

*/

if(ereg("^{\colortbl", $rtfile[$i])) {

// Split the line by the backslash.

$colors = explode("\", $rtfile[$i]);

$numOfColors = count($colors);

for($k = 2; $k < $numOfColors; $k ) {

// Find out how many different colors th

// ere are.

if(ereg("[0-9] ", $colors[$k], $matches)) {

$match[] = $matches[0];

}

}

// For each color, convert it to hex.

$numOfColors = count($match);

for($k = 0; $k < $numOfColors; $k = 3) {

$red = dechex($match[$k]);

$red = $match[$k] < 16 ? "0$red" : $red;

$green = dechex($match[$k 1]);

$green = $match[$k 1] < 16 ? "0$green" : $green;

$blue = dechex($match[$k 2]);

$blue = $match[$k 2] < 16 ? "0$blue" : $blue;

$fcolor[] = "$red$green$blue";

}

$numOfColors = count($fcolor);

}

// Or else, we parse the line, pulling o

// ff words and tags.

else {

$token = "";

$start = 0;

$lineLength = strlen($rtfile[$i]);

for($k = 0; $k < $lineLength; $k ) {

if($rtfile[$i][$start] == "\"

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值