Skip to content

Commit

Permalink
fixed #88
Browse files Browse the repository at this point in the history
  • Loading branch information
gam6itko committed Aug 3, 2020
1 parent 397013e commit 7060eed
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/XBase/Column/DBaseColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace XBase\Column;

use XBase\Enum\FieldType;
use XBase\Record;
use XBase\Stream\Stream;

class DBaseColumn extends AbstractColumn
Expand Down Expand Up @@ -40,8 +39,11 @@ public static function create(string $memoryChunk, int $colIndex, ?int $bytePos

public function __construct(string $name, string $type, int $memAddress, int $length, int $decimalCount, $reserved1, int $workAreaID, $reserved2, bool $setFields, $reserved3, bool $indexed, int $colIndex, ?int $bytePos = null)
{
$name = (false !== strpos($name, chr(0x00))) ? substr($name, 0, strpos($name, chr(0x00))) : $name;

$this->rawName = $name;
$this->name = strtolower(rtrim($name, chr(0x00)));
// chop all garbage from 0x00
$this->name = strtolower($name);
$this->type = $type;
$this->memAddress = $memAddress;
$this->length = $length;
Expand Down
2 changes: 0 additions & 2 deletions src/XBase/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,6 @@ public function getVersion()

/**
* @see Codepage
*
* @return int
*/
public function getLanguageCode(): int
{
Expand Down
17 changes: 17 additions & 0 deletions tests/DbfTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace XBase\Tests;

use XBase\Enum\TableType;
use XBase\Record\DBaseRecord;
use XBase\Table;

class DbfTest extends AbstractTestCase
Expand All @@ -18,4 +19,20 @@ public function test2ByteHeaderTerminator(): void
self::assertSame([1000, 'Банк ВТБ (ПАО)', 1, 1], array_values($table->nextRecord()->getData()));
self::assertSame([990, 'ООО КБ "Дружба"', 1, 1], array_values($table->pickRecord(441)->getData()));
}

public function testIssue88(): void
{
$table = new Table(__DIR__.'/Resources/dbf/cbrf_122019N1.dbf', null, 'cp866');
/** @var DBaseRecord $record */
$record = $table->nextRecord();
self::assertSame(
[
'regn' => 1,
'name_b' => 'АО ЮниКредит Банк',
'priz' => 1,
'priz_p' => 1,
],
$record->getData()
);
}
}

0 comments on commit 7060eed

Please sign in to comment.