Skip to content

Commit

Permalink
setCharset / getCharset() added
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroendesloovere committed Jul 23, 2015
1 parent a48dfe5 commit cb40209
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
1.2.1 (2015-07-23)
--
Improvements:
* You can now set the charset by using $vcard->setCharset('ISO-8859-1');

1.2.0 (2015-06-01)
--
Improvements:
Expand Down
23 changes: 22 additions & 1 deletion src/VCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,16 @@ public function get()
return $this->getOutput();
}

/**
* Get charset
*
* @return string
*/
public function getCharset()
{
return $this->charset;
}

/**
* Get content type
*
Expand Down Expand Up @@ -517,7 +527,7 @@ public function getFileExtension()
*/
public function getHeaders($asAssociative)
{
$contentType = $this->getContentType() . '; charset=' . $this->charset;
$contentType = $this->getContentType() . '; charset=' . $this->getCharset();
$contentDisposition = 'attachment; filename=' . $this->getFilename() . '.' . $this->getFileExtension();
$contentLength = strlen($this->getOutput());
$connection = 'close';
Expand Down Expand Up @@ -619,6 +629,17 @@ public function save()
);
}

/**
* Set charset
*
* @param mixed $charset
* @return void
*/
public function setCharset($charset)
{
$this->charset = $charset;
}

/**
* Set filename
*
Expand Down
10 changes: 10 additions & 0 deletions tests/VCardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ public function testAddPhotoWithNoPhoto()
$this->vcard->addPhoto(__DIR__ . '/wrongfile', true);
}

/**
* Test charset
*/
public function testCharset()
{
$charset = 'ISO-8859-1';
$this->vcard->setCharset($charset);
$this->assertEquals($charset, $this->vcard->getCharset());
}

/**
* Test Email
*
Expand Down

0 comments on commit cb40209

Please sign in to comment.