plaintext

Rendering plain text through PHP

久未见 提交于 2019-12-22 04:03:48
问题 For some reason, I want to serve my robots.txt via a PHP script. I have setup apache so that the robots.txt file request (infact all file requests) come to a single PHP script. The code I am using to render robots.txt is: echo "User-agent: wget\n"; echo "Disallow: /\n"; However, it is not processing the newlines. How to server robots.txt correctly, so search engines (or any client) see it properly? Do I have to send some special headers for txt files? EDIT 1: Now I have the following code:

encrypt PBEWithMD5AndDES in j2me

旧街凉风 提交于 2019-12-22 01:43:34
问题 i'm triing to get this code to work on j2me (it is working a java program) but not yet in j2me public static String generate(String plaintext, String passphase) throws Exception { try { PBEKeySpec pbeKeySpec = new PBEKeySpec(passphase.toCharArray()); PBEParameterSpec pbeParamSpec; SecretKeyFactory keyFac; // Salt byte[] salt = {(byte) 0xc8, (byte) 0x73, (byte) 0x61, (byte) 0x1d, (byte) 0x1a, (byte) 0xf2, (byte) 0xa8, (byte) 0x99}; // Iteration count int count = 20; // Create PBE parameter set

Convert HTML to plain text in Java

流过昼夜 提交于 2019-12-21 09:13:56
问题 I need to convert HTML to plain text. My only requirement of formatting is to retain new lines in the plain text. New lines should be displayed not only in the case of <br> but other tags, e.g. <tr/> , </p> leads to a new line too. Sample HTML pages for testing are: http://www.particle.kth.se/~lindsey/JavaCourse/Book/Part1/Java/Chapter09/scannerConsole.html http://www.javadb.com/write-to-file-using-bufferedwriter Note that these are only random URLs. I have tried out various libraries (JSoup,

Ruby on Rails: How to render file as plain text (without any HTML)

梦想与她 提交于 2019-12-21 05:07:12
问题 How do you render file as a plain/text in rails (without rendering any HTML)? I've tried: render file: "path/to/file", layout: false and render file: "path/to/file", content_type: 'text/plain' also both render file: "path/to/file", layout: false, content_type: 'text/plain' But there still some html on the response. I'm using rails 3.2.14 and ruby 1.9.3 Thanks in advance. EDIT 1: Silly me, this actually works: render file: "path/to/file", layout: false, content_type: 'text/plain' I was

Ruby on Rails: How to render file as plain text (without any HTML)

早过忘川 提交于 2019-12-21 05:07:10
问题 How do you render file as a plain/text in rails (without rendering any HTML)? I've tried: render file: "path/to/file", layout: false and render file: "path/to/file", content_type: 'text/plain' also both render file: "path/to/file", layout: false, content_type: 'text/plain' But there still some html on the response. I'm using rails 3.2.14 and ruby 1.9.3 Thanks in advance. EDIT 1: Silly me, this actually works: render file: "path/to/file", layout: false, content_type: 'text/plain' I was

Best way to convert HTML to plaintext using Python

﹥>﹥吖頭↗ 提交于 2019-12-21 04:08:27
问题 I'm working on a project that involves converting a large amount of HTML content to plain/text. I have a custom-written module that does the job OK, but I'm wondering if there's some standard tools to help get the job done. 回答1: Html2Text seems to be a good option 回答2: Here's a python library which does HTML parsing: lxml.html BeautifulSoup is another option. 来源: https://stackoverflow.com/questions/1668081/best-way-to-convert-html-to-plaintext-using-python

How to force PHP to read newlines and returns as <br>

耗尽温柔 提交于 2019-12-20 05:00:08
问题 The title is a little off im sorry. however what the scenario IS. I'm reading from a MySQL Database the field format is "mediumtext". At current it knows when there is a new line from hitting enter/return. there is no html involved. however when i pull this from the database onto my page, there is no formatting. however if you look at the html the code it beautifuly formatted with new lines! ive already got a find/replace function setup for some simple BBCode so might be able to use this. so

Intent for editing plain text file with the installed file editor (if any)

与世无争的帅哥 提交于 2019-12-18 07:39:42
问题 I want my app to open a plain text file with any of the file editors installed on my terminal, but I keep getting this exception: ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.EDIT dat=file:///sdcard/folder/file.txt } First I thought that I have no File editor installed, but if I use ASTRO file manager, I can get to open the file both with "File Editor" and "QuickOffice", so I think the problem is that I'm not using the right code... Here is the

Intent for editing plain text file with the installed file editor (if any)

爷,独闯天下 提交于 2019-12-18 07:39:42
问题 I want my app to open a plain text file with any of the file editors installed on my terminal, but I keep getting this exception: ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.EDIT dat=file:///sdcard/folder/file.txt } First I thought that I have no File editor installed, but if I use ASTRO file manager, I can get to open the file both with "File Editor" and "QuickOffice", so I think the problem is that I'm not using the right code... Here is the

Pyparsing: Parsing semi-JSON nested plaintext data to a list

社会主义新天地 提交于 2019-12-18 05:14:19
问题 I have a bunch of nested data in a format that loosely resembles JSON: company="My Company" phone="555-5555" people= { person= { name="Bob" location="Seattle" settings= { size=1 color="red" } } person= { name="Joe" location="Seattle" settings= { size=2 color="blue" } } } places= { ... } There are many different parameters with varying levels of depth--this is just a very small subset. It also might be worth noting that when a new sub-array is created that there is always an equals sign