# Pg\_escape\_bytea / pg\_unescape\_bytea (php) alternative in Rai

**URL:** <https://www.ruby-forum.com/t/pg-escape-bytea-pg-unescape-bytea-php-alternative-in-rai/102576>\
**Category:** Rails\
**Created:** [November 7, 2006, 10:46am UTC](https://www.ruby-forum.com/t/pg-escape-bytea-pg-unescape-bytea-php-alternative-in-rai/102576 "2006-11-07T10:46:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bartm85](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/53a042/32.png) [@bartm85](https://www.ruby-forum.com/u/bartm85)\
**Post date:** [November 7, 2006, 10:46am UTC](https://www.ruby-forum.com/t/pg-escape-bytea-pg-unescape-bytea-php-alternative-in-rai/102576/1 "2006-11-07T10:46:24Z")

</div>

Is there a built-in function that handles the problem of bitstreams in  
postgresql? The problem occurs when the stream contains for example the  
" character. Postgres will think that the string has ended with that  
character. Is there a function that changes all such characters into  
“[ASCII-number]”? And the other way around when getting the stream  
back from the database?  
References:  
[http://be.php.net/manual/nl/function.pg-escape-bytea.php](http://be.php.net/manual/nl/function.pg-escape-bytea.php)  
[http://be.php.net/manual/nl/function.pg-unescape-bytea.php](http://be.php.net/manual/nl/function.pg-unescape-bytea.php)

---

<div class="post-metadata">

**Author:** ![bartm85](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/53a042/32.png) [@bartm85](https://www.ruby-forum.com/u/bartm85)\
**Post date:** [November 7, 2006, 10:47am UTC](https://www.ruby-forum.com/t/pg-escape-bytea-pg-unescape-bytea-php-alternative-in-rai/102576/2 "2006-11-07T10:47:50Z")

</div>

On 10/30/06, Bartm85 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a built-in function that handles the problem of bitstreams in  
> postgresql? The problem occurs when the stream contains for example the  
> " character. Postgres will think that the string has ended with that  
> character. Is there a function that changes all such characters into  
> “[ASCII-number]”? And the other way around when getting the stream  
> back from the database?  
> References:  
> [http://be.php.net/manual/nl/function.pg-escape-bytea.php](http://be.php.net/manual/nl/function.pg-escape-bytea.php)  
> [http://be.php.net/manual/nl/function.pg-unescape-bytea.php](http://be.php.net/manual/nl/function.pg-unescape-bytea.php)

bytea column values are automatically escaped and unescaped.

jeremy
