Skip to content

add ability to set codepage explicitly for BIFF5 #1484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 28, 2020

Conversation

boltunoreh
Copy link
Contributor

If BIFF5 excel 95 file doesn't have codepage record, the default codepage CP1252 is used and can't be change.
That causes to problems with decoding cyrillic text.

This is:

- [ ] a bugfix
- [x] a new feature

Checklist:

Why this change is needed?

It's made to add ability to read Excel 95 files with cyrillic text properly.

Copy link
Member

@MarkBaker MarkBaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this submission

/**
* @param string $codepage
*/
public function setCodepage($codepage): void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to consider typehinting, and some form of validation here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to consider typehinting, and some form of validation here

done

@@ -640,7 +648,7 @@ public function load($pFilename)

// initialize
$this->pos = 0;
$this->codepage = 'CP1252';
$this->codepage = $this->codepage == null ? 'CP1252' : $this->codepage;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps use $this->codepage = ?: 'CP1252' here.
As our minimum PHP version is 7.1, using more succinct syntax is available to us

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@MarkBaker
Copy link
Member

Also, take a look at the most recent merges to master, one of which addresses codepages

Copy link
Member

@PowerKiKi PowerKiKi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments by Mark should be addressed before merging this

@boltunoreh boltunoreh force-pushed the master branch 2 times, most recently from b1b7d18 to 80f4666 Compare June 1, 2020 12:29
@boltunoreh
Copy link
Contributor Author

Also, take a look at the most recent merges to master, one of which addresses codepages

done

public static function validate(string $codePage): bool
{
if (!in_array($codePage, self::$pageArray)) {
return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be much simplified to a single line as return (in_array($codePage, self::$pageArray, true)); with strict type checking for the codepage string as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

If BIFF5 excel 95 file doesn't have codepage record, the default codepage CP1252 is used and can't be change.
That causes to problems with decoding cyrillic text.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants