Cadena Simple de compresión


Una rutina simple para comprimir las cadenas.

Colaborador: SWAG EQUIPO de SOPORTE

{ganó & #39 t obtener ese tipo de compresión de mis rutinas, pero aquí
son todos modos. Cuando se prueba, usted & #39 ll llegar a la mejor compresión del si
el uso de inglés y de largas Cadenas.
}
Unidad de Comprimir

Interfaz

Const
CompressedStringArraySize = 500 { errar en el lado de la generosidad }

Tipo
tCompressedStringArray = Array[1..CompressedStringArraySize] de Byte

la Función de GetCompressedString(Arr : tCompressedStringArray) : String

Procedimiento CompressString(st : String Var Arr : tCompressedStringArray
Var len : Integer)
{ convierte st en un tCompressedStringArray de longitud len }

Aplicación

Const
FreqChar : Array[4..14] of Char = & #39 etaonirshdl & #39
{& #39 t en [0..3] debido a dos vacío bits significar un espacio }

la Función de GetCompressedString(Arr : tCompressedStringArray) : String
Var
Cambio : Byte
i : Integer
ch : Char
st : String
b : Byte

la Función de GetHalfNibble : Byte
begin
GetHalfNibble := (Arr[i] shr Shift) y 3
si Turno = 0 then begin
Cambio := 6
inc(i)
final más dec(Shift,2)
fin

begin
st := & #39 & #39
i := 1
Cambio := 6
Repetir
b := GetHalfNibble
si b = 0, entonces
ch := & #39 & #39
else begin
b := (b shl 2) o GetHalfNibble
si b = $F, a continuación, empezar
b := GetHalfNibble shl 6
b := b o GetHalfNibble shl 4
b := b o GetHalfNibble shl 2
b := b o GetHalfNibble
ch := Char(b)
else
ch := FreqChar[b]
fin
si ch <> #0, pt := st ch
Hasta ch = #0
GetCompressedString := st
fin

Procedimiento CompressString(st : String Var Arr : tCompressedStringArray
Var len : Integer)
{ convierte st en un tCompressedStringArray de longitud len }
Var
i : Integer
Cambio : Byte

Procedimiento OutHalfNibble(b : Byte)
begin
Arr[len] := Arr[len] o (b shl Shift)
si Turno = 0 then begin
Cambio := 6
inc(len)
final más dec(Shift,2)
fin

Procedimiento OutChar(ch : Char)
Var
i : Byte
bych : Byte Absoluta ch
begin
si ch = & #39 & #39
OutHalfNibble(0)
else begin
i := 4
Mientras (i<15) y (FreqChar[i]<>ch) inc(i)
OutHalfNibble(i shr 2)
OutHalfNibble(i y 3)
si i = $F, a continuación, empezar
OutHalfNibble(bych shr 6)
OutHalfNibble((bych shr 4) y 3)
OutHalfNibble((bych shr 2) y 3)
OutHalfNibble(bych y 3)
fin
fin
fin

begin
len := 1
Cambio := 6
fillChar(Arr,sizeof(Arr),0)
For i := 1 to length(st) hacer OutChar(st[i])
OutChar(#0) { final de los comprimidos de la Cadena señalada por #0 }
si Turno = 6
a continuación, dec(len)
fin

.









Cadena Simple de compresion


Cadena Simple de compresion : Multi-millones de consejos para hacer su vida mas facil.


Una rutina simple para comprimir las cadenas.

Colaborador: SWAG EQUIPO de SOPORTE

{gano & #39 t obtener ese tipo de compresion de mis rutinas, pero aqui
son todos modos. Cuando se prueba, usted & #39 ll llegar a la mejor compresion del si
el uso de ingles y de largas Cadenas.
}
Unidad de Comprimir

Interfaz

Const
CompressedStringArraySize = 500 { errar en el lado de la generosidad }

Tipo
tCompressedStringArray = Array[1..CompressedStringArraySize] de Byte

la Funcion de GetCompressedString(Arr : tCompressedStringArray) : String

Procedimiento CompressString(st : String Var Arr : tCompressedStringArray
Var len : Integer)
{ convierte st en un tCompressedStringArray de longitud len }

Aplicacion

Const
FreqChar : Array[4..14] of Char = & #39 etaonirshdl & #39
{& #39 t en [0..3] debido a dos vacio bits significar un espacio }

la Funcion de GetCompressedString(Arr : tCompressedStringArray) : String
Var
Cambio : Byte
i : Integer
ch : Char
st : String
b : Byte

la Funcion de GetHalfNibble : Byte
begin
GetHalfNibble := (Arr[i] shr Shift) y 3
si Turno = 0 then begin
Cambio := 6
inc(i)
final mas dec(Shift,2)
fin

begin
st := & #39 & #39
i := 1
Cambio := 6
Repetir
b := GetHalfNibble
si b = 0, entonces
ch := & #39 & #39
else begin
b := (b shl 2) o GetHalfNibble
si b = $F, a continuacion, empezar
b := GetHalfNibble shl 6
b := b o GetHalfNibble shl 4
b := b o GetHalfNibble shl 2
b := b o GetHalfNibble
ch := Char(b)
else
ch := FreqChar[b]
fin
si ch <> #0, pt := st ch
Hasta ch = #0
GetCompressedString := st
fin

Procedimiento CompressString(st : String Var Arr : tCompressedStringArray
Var len : Integer)
{ convierte st en un tCompressedStringArray de longitud len }
Var
i : Integer
Cambio : Byte

Procedimiento OutHalfNibble(b : Byte)
begin
Arr[len] := Arr[len] o (b shl Shift)
si Turno = 0 then begin
Cambio := 6
inc(len)
final mas dec(Shift,2)
fin

Procedimiento OutChar(ch : Char)
Var
i : Byte
bych : Byte Absoluta ch
begin
si ch = & #39 & #39
OutHalfNibble(0)
else begin
i := 4
Mientras (i<15) y (FreqChar[i]<>ch) inc(i)
OutHalfNibble(i shr 2)
OutHalfNibble(i y 3)
si i = $F, a continuacion, empezar
OutHalfNibble(bych shr 6)
OutHalfNibble((bych shr 4) y 3)
OutHalfNibble((bych shr 2) y 3)
OutHalfNibble(bych y 3)
fin
fin
fin

begin
len := 1
Cambio := 6
fillChar(Arr,sizeof(Arr),0)
For i := 1 to length(st) hacer OutChar(st[i])
OutChar(#0) { final de los comprimidos de la Cadena señalada por #0 }
si Turno = 6
a continuacion, dec(len)
fin

.


Cadena Simple de compresión

Cadena Simple de compresión : Multi-millones de consejos para hacer su vida más fácil.
Recommander aux amis
  • gplus
  • pinterest

Comentario

Dejar un comentario

Clasificación