当前位置: 首页>>代码示例>>Java>>正文


Java TextUtils.htmlEncode方法代码示例

本文整理汇总了Java中android.text.TextUtils.htmlEncode方法的典型用法代码示例。如果您正苦于以下问题:Java TextUtils.htmlEncode方法的具体用法?Java TextUtils.htmlEncode怎么用?Java TextUtils.htmlEncode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.text.TextUtils的用法示例。


在下文中一共展示了TextUtils.htmlEncode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: simpleTextToHtml

import android.text.TextUtils; //导入方法依赖的package包/类
/**
 * Naively convert a text string into an HTML document.
 *
 * <p>
 * This method avoids using regular expressions on the entire message body to save memory.
 * </p>
 * <p>
 * No HTML headers or footers are added to the result.  Headers and footers
 * are added at display time in
 * {@link com.fsck.k9.view#MessageWebView.setText(String) MessageWebView.setText()}
 * </p>
 *
 * @param text
 *         Plain text string.
 * @return HTML string.
 */
private static String simpleTextToHtml(String text) {
    // Encode HTML entities to make sure we don't display something evil.
    text = TextUtils.htmlEncode(text);

    StringBuilder buff = new StringBuilder(text.length() + TEXT_TO_HTML_EXTRA_BUFFER_LENGTH);

    buff.append(htmlifyMessageHeader());

    for (int index = 0; index < text.length(); index++) {
        char c = text.charAt(index);
        switch (c) {
        case '\n':
            // pine treats <br> as two newlines, but <br/> as one newline.  Use <br/> so our messages aren't
            // doublespaced.
            buff.append("<br />");
            break;
        case '\r':
            break;
        default:
            buff.append(c);
        }//switch
    }

    buff.append(htmlifyMessageFooter());

    return buff.toString();
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:44,代码来源:HtmlConverter.java

示例2: textToHtmlFragment

import android.text.TextUtils; //导入方法依赖的package包/类
/**
 * Convert a plain text string into an HTML fragment.
 * @param text Plain text.
 * @return HTML fragment.
 */
public static String textToHtmlFragment(final String text) {
    // Escape the entities and add newlines.
    String htmlified = TextUtils.htmlEncode(text);

    // Linkify the message.
    StringBuffer linkified = new StringBuffer(htmlified.length() + TEXT_TO_HTML_EXTRA_BUFFER_LENGTH);
    UriLinkifier.linkifyText(htmlified, linkified);

    // Add newlines and unescaping.
    //
    // For some reason, TextUtils.htmlEncode escapes ' into &apos;, which is technically part of the XHTML 1.0
    // standard, but Gmail doesn't recognize it as an HTML entity. We unescape that here.
    return linkified.toString().replaceAll("\r?\n", "<br>\r\n").replace("&apos;", "&#39;");
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:20,代码来源:HtmlConverter.java

示例3: HtmlDecode

import android.text.TextUtils; //导入方法依赖的package包/类
public static String HtmlDecode(String oldStr){

        if(oldStr == null || oldStr.isEmpty()) return "";

        String result = oldStr;

        result = result.replace("#015;","");
        result = result.replace("#012;","");
        result = result.replace("&amp;","&");
        result = result.replace("&","{AND}");
        result = TextUtils.htmlEncode(result);
        result = result.replace("{AND}","&");
        return result;
    }
 
开发者ID:barisatalay,项目名称:thermalprinterhelper,代码行数:15,代码来源:UtilsHtml.java

示例4: htmlEncode

import android.text.TextUtils; //导入方法依赖的package包/类
@NonNull
public static String htmlEncode(@NonNull String s) {
    return TextUtils.htmlEncode(s);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:5,代码来源:TextUtilsCompatJellybeanMr1.java

示例5: setRecognizedInput

import android.text.TextUtils; //导入方法依赖的package包/类
public void setRecognizedInput(String strRecogResult, String strRecogErr) {
	EditText txtInput = (EditText)findViewById(R.id.edtSmartMathInput);
	// if strRecogResult is null, we do not change input text.
   	if (strRecogResult != null)	{
		txtInput.setText(strRecogResult);	// clear input and set text.
   	} else {
   		txtInput.setText("");
   	}

       String strConfirm = "<p>" + getString(R.string.please_confirm_recognized_result_and_calculation_result)
			+ "<a href=\"" + AOPER_URL_HEADER + EMAIL_UNSATISFACTORY_RECOG + "\">"
			+ getString(R.string.here) + "</a>" + getString(R.string.stop_charater) + "</p>";
       String strRecogExprsOutput = "";
       if (strRecogErr == null || strRecogErr.length() == 0) {
       	if (strRecogResult == null || strRecogResult.length() == 0) {
       		// output is empty
       		strRecogExprsOutput = "<p>" + getString(R.string.no_valid_expr_recognized) + "</p>\n";
       	} else {
       		// output is not empty
               strRecogExprsOutput = "<p>" + getString(R.string.recognized_result) + "</p>"; 
       		String[] strarrayExprs = txtInput.getText().toString().split("\n");
       		String strRecognizedExprColor = "color:#008000;", strInvalidExprColor = "color:#800000;";
       		for (int idx = 0; idx < strarrayExprs.length; idx ++)	{
       			/* show the expression(s) */
       			CurPos curpos = new CurPos();
       			curpos.m_nPos = 0;
       			AbstractExpr aexpr = new AEInvalid();
                   try {
       				aexpr = ExprAnalyzer.analyseExpression(strarrayExprs[idx], curpos);
       				strRecogExprsOutput += "<p><a href=\"" + AbstractExprConverter.convtPlainStr2QuotedUrl(strarrayExprs[idx])
       							+ "\" style=\"text-decoration: none;" + strRecognizedExprColor + "\">$"
       							+ AbstractExprConverter.convtAExpr2JQMath(aexpr) + "$</a></p>\n";
                   } catch (Exception e)	{
       				strRecogExprsOutput += "<p><a href=\"" + AbstractExprConverter.convtPlainStr2QuotedUrl(strarrayExprs[idx])
       						+ "\" style=\"text-decoration: none;" + strInvalidExprColor + "\">$"
       						+ AbstractExprConverter.convtPlainStr2JQMathNoException(strarrayExprs[idx]) + "$</a></p>\n";
       				strRecogExprsOutput += "<p>&nbsp;<big>&rArr;</big>&nbsp" + getString(R.string.invalid_expr_to_analyse) + " ";
       				strRecogExprsOutput += getString(R.string.please_modify_the_input_expression) + "</p><p>"
       						+ TextUtils.htmlEncode(strarrayExprs[idx]) + "</p>\n"; 
                   }
       		}
       	}
       } else {
       	// recognition error.
       	strRecogExprsOutput = "<p>" + strRecogErr + "</p>\n";
       }
	mstrarrayTaskAndOutput[0] = "recognize";
	mstrarrayTaskAndOutput[1] = strRecogExprsOutput;	// save it to mstrOutput so that it can be reloaded after rotation.
	mshistoricalRecMgr.addRecord(strRecogResult, mstrarrayTaskAndOutput[0], mstrarrayTaskAndOutput[1], "", ActivitySettings.msnNumberofRecords);
	WebView wvOutput = (WebView) findViewById(R.id.webviewSmartMathOutput);
	wvOutput.loadDataWithBaseURL("file:///android_asset/mathscribe/index.html",
				OUTPUT_HEAD_STRING + mstrFontSize + OUTPUT_SIZE_UNIT_STRING + strConfirm + strRecogExprsOutput + OUTPUT_TAIL_STRING,
				"text/html", "utf-8", "");
	
      	// hide the soft keyboard and inputpad so that recognizing result can be shown.   		
	if (mnSoftKeyState == ENABLE_SHOW_SOFTKEY)	{
           setSoftKeyState(txtInput, ENABLE_HIDE_SOFTKEY);
	} else if (mnSoftKeyState == ENABLE_SHOW_INPUTPAD)	{
           setSoftKeyState(txtInput, ENABLE_HIDE_INPUTPAD);
	}
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:62,代码来源:ActivitySmartCalc.java


注:本文中的android.text.TextUtils.htmlEncode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。