SA-MP Forums Archive
[Tutorial] Packed and Unpacked strings (PAWN) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Packed and Unpacked strings (PAWN) (/showthread.php?tid=342729)



Packed and Unpacked strings (PAWN) - kizla - 14.05.2012

Packed and unpacked strings

The PAWN language does not have variable types. All variables are "cells" which are typically 32-bit wide (there exist implementations of PAWN that use 64-bit cells). A string is basically an array of cells that holds characters and that is terminated with the special character '\0'.

However, in most character sets a character typically takes only a single byte and a cell typicall is a four-byte entity: storing a single character per cell is then a 75% waste. For the sake of compactness, PAWN supports packed strings, where each cell holds as many characters as fit. In our example, one cell would contain four characters, and there is no space wasted.

At the same time, PAWN also supports unpacked strings where each cell holds only a single character, with the purpose of supporting Unicode or other wide-character sets. The Unicode character set is usually represented as a 16-bit character set holding the 60,000 characters of the Basic Multilingual Plane (BMP), and access to other "planes" trough escape codes. A PAWN script can hold all characters of all planes in a cell, since a cell is typically at least 32-bit, without needing escape codes.

Many programming language solve handling of ASCII/Ansi character sets versus Unicode with their typing system. A function will then work either on one or on the other type of string, but the types cannot be mixed. PAWN, on the other hand, does not have types or a typing system, but it can check, at run time, whether a string a packed or unpacked. This also enables you to write a single function that operates on both packed and unpacked strings. The functions in the String Manipulation Library have been constructed so that they work on packed and unpacked strings.

This tutorial is to better familiarize PAWN structure and more about it...


Re: Packed and Unpacked strings (PAWN) - Vince - 14.05.2012

Straight copy: http://www.compuphase.com/pawn/String_Manipulation.pdf


Re: Packed and Unpacked strings (PAWN) - Face9000 - 14.05.2012

GG copying this from CompuPhase.com - String Manipulation.


Re: Packed and Unpacked strings (PAWN) - Hiddos - 15.05.2012

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
GG quoting the post above

Meh, was hoping about a tutorial on this instead of a dictionary.


Re: Packed and Unpacked strings (PAWN) - Hanger - 16.05.2012

I would want to know how to use them with multi-dimensional arrays/strings, how to use them in format function etc. This tells me nothing.