Модераторы: korob2001, ginnie
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> [XBase] хранение запакованных чисел в CHAR-поле 
:(
    Опции темы
falls
Дата 11.3.2008, 15:40 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 1
Регистрация: 11.3.2008

Репутация: нет
Всего: нет



perl -e 'my $dbf = CAM::DBF->new("db.dbf");for my $column (0.. $dbf->nfields-1) {print "column $column ".$dbf->fieldname($column)." is ".$dbf->fieldtype($column)."; "} my @fields=$dbf->fetchrow_array(5); print join("|", @fields)."\n";'

В случае с одной базой имеют место быть данные вида:
column 0 Borough is C; column 1 Block is N..
BX|2267|55|201|

В случае с другой:
column 0 Borough is C; column 1 Block is C..
BX|��@|7|�|

Что бы скормить unpack, чтобы привести строку к читаемому виду?

Это сообщение отредактировал(а) falls - 12.3.2008, 12:54
PM MAIL   Вверх
nitr
Дата 20.3.2008, 21:28 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Эксперт
****


Профиль
Группа: Участник Клуба
Сообщений: 2543
Регистрация: 10.2.2006
Где: Россия :)

Репутация: 37
Всего: 84



Лучше вложением кусочек выложить, а то отображение в браузере...
Вариантов с unpack бывает много smile , в вашем случае можно подбирать, если не знаете который.
perldoc -f pack
perldoc -f unpack
Цитата
...
    a   A string with arbitrary binary data, will be null padded.
    A   A text (ASCII) string, will be space padded.
    Z   A null terminated (ASCIZ) string, will be null padded.
    b   A bit string (ascending bit order inside each byte, like vec()).
    B   A bit string (descending bit order inside each byte).
    h   A hex string (low nybble first).
    H   A hex string (high nybble first).
    c   A signed char value.
    C   An unsigned char value.  Only does bytes.  See U for Unicode.
    s   A signed short value.
    S   An unsigned short value.
          (This 'short' is _exactly_ 16 bits, which may differ from
           what a local C compiler calls 'short'.  If you want
           native-length shorts, use the '!' suffix.)
    i   A signed integer value.
    I   An unsigned integer value.
          (This 'integer' is _at_least_ 32 bits wide.  Its exact
           size depends on what a local C compiler calls 'int',
           and may even be larger than the 'long' described in
           the next item.)
    l   A signed long value.
    L   An unsigned long value.
          (This 'long' is _exactly_ 32 bits, which may differ from
           what a local C compiler calls 'long'.  If you want
           native-length longs, use the '!' suffix.)
    n   An unsigned short in "network" (big-endian) order.
    N   An unsigned long in "network" (big-endian) order.
    v   An unsigned short in "VAX" (little-endian) order.
    V   An unsigned long in "VAX" (little-endian) order.
          (These 'shorts' and 'longs' are _exactly_ 16 bits and
           _exactly_ 32 bits, respectively.)
    q   A signed quad (64-bit) value.
    Q   An unsigned quad value.
          (Quads are available only if your system supports 64-bit
           integer values _and_ if Perl has been compiled to support those.
           Causes a fatal error otherwise.)
    j   A signed integer value (a Perl internal integer, IV).
    J   An unsigned integer value (a Perl internal unsigned integer, UV).
    f   A single-precision float in the native format.
    d   A double-precision float in the native format.
    F   A floating point value in the native native format
           (a Perl internal floating point value, NV).
    D   A long double-precision float in the native format.
          (Long doubles are available only if your system supports long
           double values _and_ if Perl has been compiled to support those.
           Causes a fatal error otherwise.)
    p   A pointer to a null-terminated string.
    P   A pointer to a structure (fixed-length string).
    u   A uuencoded string.
    U   A Unicode character number.  Encodes to UTF-8 internally
        (or UTF-EBCDIC in EBCDIC platforms).
    w   A BER compressed integer.  Its bytes represent an unsigned
        integer in base 128, most significant digit first, with as
        few digits as possible.  Bit eight (the high bit) is set
        on each byte except the last.
    x   A null byte.
    X   Back up a byte.
    @   Null fill to absolute position, counted from the start of
        the innermost ()-group.
    (   Start of a ()-group.
...



--------------------
PM   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Правила форума "Perl"
korob2001
sharq
  • В этом разделе обсуждаются общие вопросы по языку Perl
  • Если ваш вопрос относится к системному программированию, задавайте его здесь
  • Если ваш вопрос относится к CGI программированию, задавайте его здесь
  • Интерпретатор Perl можно скачать здесь ActiveState, O'REILLY, The source for Perl
  • Справочное руководство "Установка perl-модулей", можно скачать здесь


Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, korob2001, sharq.

 
1 Пользователей читают эту тему (1 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | Perl: Общие вопросы | Следующая тема »


 




[ Время генерации скрипта: 0.0633 ]   [ Использовано запросов: 21 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.