No matter what you do you're in some sort of character encoding hell (that's just the way it is with character encodings).
From http://labs.apache.org/webarch/uri/rfc/rfc3986.html#characters:
The URI syntax provides a method of encoding data, presumably for the sake of identifying a resource, as a sequence of characters. The URI characters are, in turn, frequently encoded as octets for transport or presentation. This specification does not mandate any particular character encoding for mapping between URI characters and the octets used to store or transmit those characters. When a URI appears in a protocol element, the character encoding is defined by that protocol; without such a definition, a URI is assumed to be in the same character encoding as the surrounding text.
So, at some point you need to convert your URI to to the encoding that's appropriate to whatever you're sending the URI to. If that's UTF8 then you might as well do that conversion before you perform percent-encoding so you can use the library routine you've already found. If it's not UTF8 then you need to know what the recipient of the URI is expecting (again, that's the way it is with charset encodings - you have to know what the other guy is expecting, or be able to tell him) so you can percent-encode the characters in the character set encoding it's expecting.