aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Enderlin <ivan.enderlin@hoa-project.net>2013-08-08 10:53:49 +0200
committerIvan Enderlin <ivan.enderlin@hoa-project.net>2013-08-08 10:53:49 +0200
commitb73b0fe1798214acb1df8ed4695c5219f96e47a2 (patch)
tree8d10834bb9de6d8f64ac91243ee99733e14efb14
parent38d2f90c4698342b91937b187853e46cafca3ed6 (diff)
downloadUstring-b73b0fe1798214acb1df8ed4695c5219f96e47a2.zip
Ustring-b73b0fe1798214acb1df8ed4695c5219f96e47a2.tar.gz
Ustring-b73b0fe1798214acb1df8ed4695c5219f96e47a2.tar.bz2
Add the toBinaryCode() static method.
-rw-r--r--String.php13
1 files changed, 13 insertions, 0 deletions
diff --git a/String.php b/String.php
index 6fb5d42..7c1c13c 100644
--- a/String.php
+++ b/String.php
@@ -761,6 +761,19 @@ class String implements \ArrayAccess, \Countable, \IteratorAggregate {
}
/**
+ * Get a binary representation of the decimal code of a specific character.
+ *
+ * @access public
+ * @param string $char Character.
+ * @param int $length Length of the binary result.
+ * @return string
+ */
+ public static function toBinaryCode ( $char, $length = 32 ) {
+
+ return vsprintf('%0' . intval($length) . 'b', static::toCode($char));
+ }
+
+ /**
* Transcode.
*
* @access public