Text


One Character

Text in a computer is stored and manipulated as a collection of characters. The example below shows how to declare one variable to store the capital letter A.
El texto en una computadora y manipulado como una colección de letras. El ejemplo de abajo muestra como declarar una variable para almacenar la letra mayúscula A.

Program.cpp
void Program::Window_Open(Win::Event& e)
{
     wchar_t oneCharacter = 'A';
}

Text using wchar_t

It is possible to store text using the operator []. The example below shows how to declare one variable to store the word Microsoft.
Es posible almacenar texto usando el operador []. El ejemplo de abajo muestra como declarar una variable para almacenar la palabra Microsoft.

Program.cpp
void Program::Window_Open(Win::Event& e)
{
     wchar_t text[] = L"Microsoft";
}

Text using wstring

It is possible to store text using wstring from the Standard Template Library STL. The example below shows how to declare one variable to store the word Microsoft.
Es posible almacenar texto usando wstring de la Librería Estándar de Plantillas (STL). El ejemplo de abajo muestra como declarar una variable para almacenar la palabra Microsoft.

Program.cpp
void Program::Window_Open(Win::Event& e)
{
     wstring text = L"Microsoft";
}

Tip
The computer stores the text as collection of letters as shown in the figure. Observe that each letter can be accessed using the operator []. Observe also that after the last letter there is a \0 which indicates the end of the text, this character is called NULL character.
La computadora almacena el texto como una colección de letras como se muestra en la figura. Observe que cada letra usando el operador []. También observe que después de la última letra hay un \0 el cual indica el final del texto, este carácter se llama carácter nulo.

NullTerminator

Tip
It is easier to manipulate text using wstring than using wchar_t. The data type wchar_t allows creating very efficient programs. Always use wstring to manipulate text, if it the program performance is not satisfactory for the application, then you should use wchar_t.
Es más fácil manipular texto usando wstring que usando wchar_t. El tipo de datos wchar_t permite crear programas muy eficientes. Siempre use wstring para manipular texto, si el desempeño del programa no es satisfactorio para la aplicación, entonces se debe usar wchar_t.

Tip
In order to use wstring, you should include the library string. Wintempla includes automatically this library.
A fin de utilizar wstring, usted debe incluir la librería string. Wintempla incluye automáticamente esta librería.

Tip
javaThe following code shows how to declare a text string in Java.
El código de abajo muestra como declarar una cadena de texto en Java.

MyProgram.java
class MyProgram
{
     public MyProgram()
     {
          String text = new String("Hello from Java");
     }
};

Tip
javaJava has three main classes to manipulate text:
  1. String class To manage text for general purposes oriented for constant text
  2. StringBuffer class To manage large amounts of text efficiently
  3. StringTokenizer class To separate text that is delimited by tokens
The following example shows how to use StringTokenizer.
Java cuenta con tres clases principales para manipular texto:
  1. String class Para manejar texto de propósito general orientado a texto fijo
  2. StringBuffer class Para manejar grandes cantidades de texto en forma eficiente
  3. StringTokenizer classPara separar texto que se encuentra delimitado por tokens
El siguiente ejemplo muestra cómo usar el StringTokenizer.

Program.java
import java.util.StringTokenizer;

public class Program
{
     public static void main(String[] args)
     {
          StringTokenizer st = new StringTokenizer("Omar#Alix#Cecilia#Rafael", "#");
          System.out.println("The total number of client is " + st.countTokens());

           while (st.hasMoreTokens() == true)
          {
               System.out.println(st.nextToken());
          }
     }
}


Sys::TextAssistant

The class Sys::TextAssistant of Wintempla has several methods to manipulate text.
La clase Sys::TextAssistant de Wintempla tiene varios métodos para manipular texto.

© Copyright 2000-2021 Wintempla selo. All Rights Reserved. Jul 22 2021. Home