Decode lines.

@param text the text
@return the byte[]
558288
public static byte[] decodeLines(final String text) {
       char[] buf = new char[text.length()];
       int pValue = 0;
       for (int ip = 0; ip < text.length(); ip++) {
           final char cValue = text.charAt(ip);
           if (cValue != ' ' && cValue != '\r' && cValue != '\n' && cValue != '\t') {
               buf[pValue++] = cValue;
           }
       }
       return decode(buf, 0, pValue);
   }
607667
public static String makeLinear (String text)
    {
        if (text == null) {
            return text;
        }
        // handle both line ending formats
        text = text.replace("\n", "<br>\n");
        return text;
    }
370138
public String encryptText(String text)
	throws Exception
	{
		return toByteText(this.encrypt(text.getBytes(IO.CHARSET)));

	}
411786
private function _decode($text)
    {
        $marc = new $this->record_class($this);

        // fallback on the actual byte length
        $record_length = strlen($text);

        $matches = array();
        if (preg_match("/^(\d{5})/", $text, $matches)) {
            // Store record length
            $record_length = $matches[1];
            if ($record_length != strlen($text)) {
                $marc->addWarning(File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INCORRECT_LENGTH], array("record_length" => $record_length, "actual" => strlen($text))));
                // Real beats declared byte length
                $record_length = strlen($text);
            }
        } else {
            $marc->addWarning(File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_NONNUMERIC_LENGTH], array("record_length" => substr($text, 0, 5))));
        }

        if (substr($text, -1, 1) != File_MARC::END_OF_RECORD)
             throw new File_MARC_Exception(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_TERMINATOR], File_MARC_Exception::ERROR_INVALID_TERMINATOR);

        // Store leader
        $marc->setLeader(substr($text, 0, File_MARC::LEADER_LEN));

        // bytes 12 - 16 of leader give offset to the body of the record
        $data_start = 0 + substr($text, 12, 5);

        // immediately after the leader comes the directory (no separator)
        $dir = substr($text, File_MARC::LEADER_LEN, $data_start - File_MARC::LEADER_LEN - 1);  // -1 to allow for \x1e at end of directory

        // character after the directory must be \x1e
        if (substr($text, $data_start-1, 1) != File_MARC::END_OF_FIELD) {
            $marc->addWarning(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_NO_DIRECTORY]);
        }

        // All directory entries 12 bytes long, so length % 12 must be 0
        if (strlen($dir) % File_MARC::DIRECTORY_ENTRY_LEN != 0) {
            $marc->addWarning(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_DIRECTORY_LENGTH]);
        }

        // go through all the fields
        $nfields = strlen($dir) / File_MARC::DIRECTORY_ENTRY_LEN;
        for ($n=0; $n<$nfields; $n++) {
            // As pack returns to key 1, leave place 0 in list empty
            list(, $tag) = unpack("A3", substr($dir, $n*File_MARC::DIRECTORY_ENTRY_LEN, File_MARC::DIRECTORY_ENTRY_LEN));
            list(, $len) = unpack("A3/A4", substr($dir, $n*File_MARC::DIRECTORY_ENTRY_LEN, File_MARC::DIRECTORY_ENTRY_LEN));
            list(, $offset) = unpack("A3/A4/A5", substr($dir, $n*File_MARC::DIRECTORY_ENTRY_LEN, File_MARC::DIRECTORY_ENTRY_LEN));

            // Check directory validity
            if (!preg_match("/^[0-9A-Za-z]{3}$/", $tag)) {
                $marc->addWarning(File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_DIRECTORY_TAG], array("tag" => $tag)));
            }
            if (!preg_match("/^\d{4}$/", $len)) {
                $marc->addWarning(File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_DIRECTORY_TAG_LENGTH], array("tag" => $tag, "len" => $len)));
            }
            if (!preg_match("/^\d{5}$/", $offset)) {
                $marc->addWarning(File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_DIRECTORY_OFFSET], array("tag" => $tag, "offset" => $offset)));
            }
            if ($offset + $len > $record_length) {
                $marc->addWarning(File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_DIRECTORY], array("tag" => $tag)));
            }

            $tag_data = substr($text, $data_start + $offset, $len);

            if (substr($tag_data, -1, 1) == File_MARC::END_OF_FIELD) {
                /* get rid of the end-of-tag character */
                $tag_data = substr($tag_data, 0, -1);
                $len--;
            } else {
                $marc->addWarning(File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_FIELD_EOF], array("tag" => $tag)));
            }

            if (preg_match("/^\d+$/", $tag) and ($tag < 10)) {
                $marc->appendField(new File_MARC_Control_Field($tag, $tag_data));
            } else {
                $subfields = explode(File_MARC::SUBFIELD_INDICATOR, $tag_data);
                $indicators = array_shift($subfields);

                if (strlen($indicators) != 2) {
                    $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_INVALID_INDICATORS], array("tag" => $tag, "indicators" => $indicators));
                    $marc->addWarning($errorMessage);
                    // Do the best with the indicators we've got
                    if (strlen($indicators) == 1) {
                        $ind1 = $indicators;
                        $ind2 = " ";
                    } else {
                        list($ind1,$ind2) = array(" ", " ");
                    }
                } else {
                    $ind1 = substr($indicators, 0, 1);
                    $ind2 = substr($indicators, 1, 1);
                }

                // Split the subfield data into subfield name and data pairs
                $subfield_data = array();
                foreach ($subfields as $subfield) {
                    if (strlen($subfield) > 0) {
                        $subfield_data[] = new File_MARC_Subfield(substr($subfield, 0, 1), substr($subfield, 1));
                    } else {
                         $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_EMPTY_SUBFIELD], array("tag" => $tag));
                         $marc->addWarning($errorMessage);
                    }
                }

                if (!isset($subfield_data)) {
                     $errorMessage = File_MARC_Exception::formatError(File_MARC_Exception::$messages[File_MARC_Exception::ERROR_EMPTY_SUBFIELD], array("tag" => $tag));
                     $marc->addWarning($errorMessage);
                }


                // If the data is invalid, let's just ignore the one field
                try {
                    $new_field = new File_MARC_Data_Field($tag, $subfield_data, $ind1, $ind2);
                    $marc->appendField($new_field);
                } catch (Exception $e) {
                    $marc->addWarning($e->getMessage());
                }
            }
        }

        return $marc;
    }
1124514
public static final byte[] getISOBytes(String text)
    {
        if (text == null)
            return null;
        int len = text.length();
        byte b[] = new byte[len];
        for (int k = 0; k < len; ++k)
            b[k] = (byte)text.charAt(k);
        return b;
    }

/**
 * Let the writer know that all writing has to be paused.
 */

    public void pause() {
        pause = true;
    }
    
    /**
     * Checks if writing is paused.
     *
     * @return		<CODE>true</CODE> if writing temporarily has to be paused, <CODE>false</CODE> otherwise.
     */
    
    public boolean isPaused() {
        return pause;
    }

/**
 * Let the writer know that writing may be resumed.
 */

    public void resume() {
        pause = false;
    }

/**
 * Flushes the <CODE>BufferedOutputStream</CODE>.
 */

    public void flush() {
        try {
            os.flush();
        }
        catch(IOException ioe) {
            throw new ExceptionConverter(ioe);
        }
    }

/**
 * Writes a <CODE>String</CODE> to the <CODE>OutputStream</CODE>.
 *
 * @param string    the <CODE>String</CODE> to write
 * @throws IOException
 */

    protected void write(String string) throws IOException {
        os.write(getISOBytes(string));
    }

/**
 * Writes a number of tabs.
 *
 * @param   indent  the number of tabs to add
 * @throws IOException
 */

    protected void addTabs(int indent) throws IOException {
        os.write(NEWLINE);
        for (int i = 0; i < indent; i++) {
            os.write(TAB);
        }
    }

/**
 * Writes a key-value pair to the outputstream.
 *
 * @param   key     the name of an attribute
 * @param   value   the value of an attribute
 * @throws IOException
 */

    protected void write(String key, String value)
    throws IOException {
        os.write(SPACE);
        write(key);
        os.write(EQUALS);
        os.write(QUOTE);
        write(value);
        os.write(QUOTE);
    }

/**
 * Writes a starttag to the outputstream.
 *
 * @param   tag     the name of the tag
 * @throws IOException
 */

    protected void writeStart(String tag)
    throws IOException {
        os.write(LT);
        write(tag);
    }

/**
 * Writes an endtag to the outputstream.
 *
 * @param   tag     the name of the tag
 * @throws IOException
 */

    protected void writeEnd(String tag)
    throws IOException {
        os.write(LT);
        os.write(FORWARD);
        write(tag);
        os.write(GT);
    }

/**
 * Writes an endtag to the outputstream.
 * @throws IOException
 */

    protected void writeEnd()
    throws IOException {
        os.write(SPACE);
        os.write(FORWARD);
        os.write(GT);
    }

/**
 * Writes the markup attributes of the specified <CODE>MarkupAttributes</CODE>
 * object to the <CODE>OutputStream</CODE>.
 * @param markup   a <CODE>Properties</CODE> collection to write.
 * @return true, if writing the markup attributes succeeded
 * @throws IOException
 */
    protected boolean writeMarkupAttributes(Properties markup)
    throws IOException {
    	if (markup == null) return false;
    	Iterator attributeIterator = markup.keySet().iterator();
    	String name;
    	while (attributeIterator.hasNext()) {
    		name = String.valueOf(attributeIterator.next());
    		write(name, markup.getProperty(name));
    	}
    	markup.clear();
    	return true;
    }

    /** Checks if the stream is to be closed on document close
     * @return true if the stream is closed on document close
     *
     */
    public boolean isCloseStream() {
        return closeStream;
    }
    
    /** Sets the close state of the stream after document close
     * @param closeStream true if the stream is closed on document close
     *
     */
    public void setCloseStream(boolean closeStream) {
        this.closeStream = closeStream;
    }
    
    /**
     * @see com.lowagie.text.DocListener#setMarginMirroring(boolean)
     */
    public boolean setMarginMirroring(boolean MarginMirroring) {
        return false;
    }
    
    /**
     * @see com.lowagie.text.DocListener#setMarginMirroring(boolean)
     * @since	2.1.6
     */
    public boolean setMarginMirroringTopBottom(boolean MarginMirroring) {
        return false;
    }
1086207
public static ByteBuffer toByteBuffer(String text) {
        notNull("text", text);
        if (text.isEmpty()) {
            return ByteBuffer.allocate(0);
        }
        return ByteBuffer.wrap(text.getBytes(UTF_8));
    }
238990
function(text, pad) {
			var result = [];
			var lines = this.splitByLines(text);
			var nl = '\n';
				
			result.push(lines[0]);
			for (var j = 1; j < lines.length; j++) 
				result.push(nl + pad + lines[j]);
				
			return result.join('');
		}
1087569
public static byte[] decode(String s) {
        if (s == null) {
            throw new NullPointerException("Input string was null.");
        }

        byte[] bytes = s.getBytes(UTF_8);
        return decode(bytes, 0, bytes.length);
    }
942477
public static byte[] convertStringToBinary(String text,String encoding)
    {
        byte[] data=null;
        if(text!=null)
        {
            if(text.length()==0)
            {
                data=new byte[0];
            }
            else
            {
                //get logger
                LoggerManager loggerManager=LoggerManager.getInstance();
                Logger logger=loggerManager.getLogger();

                String encodingToUse=encoding;
                if((encodingToUse!=null)&&(encodingToUse.length()>0))
                {
                    try
                    {
                        data=text.getBytes(encodingToUse);
                    }
                    catch(UnsupportedEncodingException exception)
                    {
                        logger.logError(new Object[]{"Unable to convert text to binary using encoding: ",encodingToUse," using default system encoding."},exception);
                    }
                }
                
                if(data==null)
                {
                    encodingToUse=IOHelper.getDefaultEncoding();

                    try
                    {
                        data=text.getBytes(encodingToUse);
                    }
                    catch(UnsupportedEncodingException exception)
                    {
                        logger.logError(new Object[]{"Unable to convert text to binary using default encoding: ",encodingToUse},exception);
                        
                        throw new FaxException("Unable to convert text to binary using encoding: "+encodingToUse,exception);
                    }
                }
            }
        }
        
        return data;
    }
1119544
def decode(self, text):
        
        # only decode byte strings into unicode if it hasn't already
        # been done by a subclass
        if isinstance(text, six.text_type):
            return text

        # empty text? nothing to decode
        if not text:
            return u''

        # use chardet to automatically detect the encoding text
        result = chardet.detect(text)
        return text.decode(result['encoding'])
257255
public List<Mistake> checkText(String text) {
    List<Mistake> mistakes = null;
    try {
      mistakes = analyseAndCheckText(text).mistakes;
    } catch (IndexOutOfBoundsException e) {
      LOGGER.fatal("Failed to process text: " + text, e);
      throw new RuntimeException(e);
    }
    return mistakes;

  }
634277
def decode(cls, line):
        
        if line.encoded:
            encoding = getattr(line, 'encoding_param', None)
            if encoding and encoding.upper() == cls.base64string:
                line.value = codecs.decode(self.value.encode("utf-8"), "base64").decode(encoding)
            else:
                line.value = stringToTextValues(line.value)[0]
            line.encoded=False
432371
static BankInfo parse(String text) {
        BankInfo info = new BankInfo();
        if (text == null || text.length() == 0)
            return info;

        String[] cols = text.split("\\|");
        info.setName(getValue(cols, 0));
        info.setLocation(getValue(cols, 1));
        info.setBic(getValue(cols, 2));
        info.setChecksumMethod(getValue(cols, 3));
        info.setRdhAddress(getValue(cols, 4));
        info.setPinTanAddress(getValue(cols, 5));
        info.setRdhVersion(HBCIVersion.byId(getValue(cols, 6)));
        info.setPinTanVersion(HBCIVersion.byId(getValue(cols, 7)));

        return info;
    }
996897
public List<AnalyzedSentence> analyzeText(String text) throws IOException {
    List<String> sentences = sentenceTokenize(text);
    return analyzeSentences(sentences);
  }
83648
public static byte [] readLine(LineReader lineReader) 
  throws IOException {
    Text out = new Text();
    long bytes = lineReader.readLine(out);
    if (bytes <= 0)
      return null;
    return out.getBytes();
  }
37162
def read_plain_text(fname, encoding="utf-8"):
    """"""
    with io.open(fname, encoding=encoding) as f:
        result = list(f)
    if result:
        if result[-1][-1:] == "\n":
            result.append("\n")
        else:
            result[-1] += "\n"
        return [line[:-1] for line in result]
    return []
1362531
function decodeWrap(text) {
        if (!text) {
            return '';
        }
        var textArr = [],
            WRAP_TEXT = ['\\', '\\', 'n'];
        for (var i = 0, j = 0, l = text.length; i < l; i++) {
            if (text[i] === WRAP_TEXT[j]) {
                j++;
                if (j === 3) {
                    j = 0;
                    textArr.push('\\n');
                }
                continue;
            }
            switch (j) {
                case 0: {
                    textArr.push(text[i]);
                    j = 0;
                    break;
                }
                case 1: {
                    if (text[i] === 'n') {
                        textArr.push('\n');
                    } else {
                        textArr.push(text[i-1], text[i]);
                    }
                    j = 0;
                    break;
                }
                case 2: {
                    textArr.push(text[i-2]);
                    if (text[i] !== '\\') {
                        j = 0;
                        textArr.push(text[i-1], text[i]);
                    }
                    break;
                }
            }
        }
        return textArr.join('');
    }