Sponsored Content
Full Discussion: Shell Uri Encoding
Top Forums Shell Programming and Scripting Shell Uri Encoding Post 302301090 by cfajohnson on Wednesday 25th of March 2009 09:22:32 PM
Old 03-25-2009
Quote:
Originally Posted by Trump
It really to make for Russian?

from "тест" to "%D1%82%D0%B5%D1%81%D1%82"

This function works in bash:

Code:
#@ uri_escape - convert STRING to hex-encoded string 
#@              and assign to optional VAR or _URI_ESCAPE
#@ Author: Chris F.A. Johnson, 2009-03-25
##
uri_escape() #@ USAGE: uri_escape STRING [VAR]
{
  local string x
  string=$1
  var=${2:-_URI_ESCAPE}

  while [ -n "$string" ] ## loop until $string is empty 
  do
     case $string in

       ## If alphanumeric or underscore, add it unchanged
       [_a-zA-Z0-9]* ) printf -v x "%s%c" "$x" "$string" ;;

       ## ...otherwise convert first character to hexadecimal
       *) printf -v x "%s%%%X" "$x" "'$string" ;;

     esac
     string=${string#?} ## remove first character from string
  done
  eval "$var=\$x"
}

uri_escape "тест" encoded

printf "%s\n" "$encoded"


Last edited by cfajohnson; 03-25-2009 at 10:49 PM..
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

encoding

Hi, I'm using putty and when I try to write ü it writes | (or when I try to write é , it writes i) I tried to change settings/translation of putty but with no success I have KSH # locale LANG= LC_CTYPE="C" LC_NUMERIC="C" LC_TIME="C" LC_COLLATE="C" LC_MONETARY="C" LC_MESSAGES="C"... (3 Replies)
Discussion started by: palmer18
3 Replies

2. Debian

URI Devices issue

Hi gurus, I would like to migrate our windows print server to a debian linux but im newbie and i dont understand. when i try to add printer into Cups im going to localhost:631 and adding printers but i see this URI devices and i dont know how to deal with them? my test scenario is like this: A... (0 Replies)
Discussion started by: saveka
0 Replies

3. Shell Programming and Scripting

In PHP replacing text between TAGS & URI information in Title Tag

Hi, what I am trying to do in PHP, is to replace the Title. I need some of the URL information inside aswell depending on the domain. The title is always different so I need to store it in a variable, put the url info like described below in front of it. Here is an example how it should... (0 Replies)
Discussion started by: lowmaster
0 Replies

4. UNIX for Advanced & Expert Users

Proxy must be specified as absolute URI

I encounter frequently a problem when installing Perl modules as follows: perl -MCPAN -e 'install Family::Module' The error message is: Proxy must be specified as absolute URI; ' ' is not at /usr/local/lib/perl5/5.8.8/CPAN.pm line 2357 even though I am not behind a proxy. Forcing to install the... (4 Replies)
Discussion started by: figaro
4 Replies

5. Shell Programming and Scripting

How to find the file encoding and updating the file encoding?

Hi, I am beginner to Unix. My requirement is to validate the encoding used in the incoming file(csv,txt).If it is encoded with UTF-8 format,then the file should remain as such otherwise i need to chnage the encoding to UTF-8. Please advice me how to proceed on this. (7 Replies)
Discussion started by: cnraja
7 Replies

6. Web Development

Iplanet webserver retaining the URI query string data.

Current Situation: 1. Visit: https://xyz.com/2015/september?trackingparam=1234 2. The URL is missing the trailing / after the “september” directory 3. The URL is redirected and rewritten to: https://xyz.com/2015/september/ , dropping the query string data. Note:... (0 Replies)
Discussion started by: raghur77
0 Replies

7. Web Development

Apache website uri access

Hi i would like to grant access specific to one uri and rest of them should be denied. as follows: http://websitename/example user should be able to access htttp://websitename/other user should be denied (1 Reply)
Discussion started by: raghur77
1 Replies

8. Solaris

View file encoding then change encoding.

Hi all!! I´m using command file -i myfile.xml to validate XML file encoding, but it is just saying regular file . I´m expecting / looking an output as UTF8 or ANSI / ASCII Is there command to display the files encoding? Thank you! (2 Replies)
Discussion started by: mrreds
2 Replies
CPANPLUS::Shell(3pm)					 Perl Programmers Reference Guide				      CPANPLUS::Shell(3pm)

NAME
CPANPLUS::Shell SYNOPSIS
use CPANPLUS::Shell; # load the shell indicated by your # config -- defaults to # CPANPLUS::Shell::Default use CPANPLUS::Shell qw[Classic] # load CPANPLUS::Shell::Classic; my $ui = CPANPLUS::Shell->new(); my $name = $ui->which; # Find out what shell you loaded $ui->shell; # run the ui shell DESCRIPTION
This module is the generic loading (and base class) for all "CPANPLUS" shells. Through this module you can load any installed "CPANPLUS" shell. Just about all the functionality is provided by the shell that you have loaded, and not by this class (which merely functions as a generic loading class), so please consult the documentation of your shell of choice. BUG REPORTS
Please report bugs or other issues to <bug-cpanplus@rt.cpan.org<gt>. AUTHOR
This module by Jos Boumans <kane@cpan.org>. COPYRIGHT
The CPAN++ interface (of which this module is a part of) is copyright (c) 2001 - 2007, Jos Boumans <kane@cpan.org>. All rights reserved. This library is free software; you may redistribute and/or modify it under the same terms as Perl itself. SEE ALSO
CPANPLUS::Shell::Default, CPANPLUS::Shell::Classic, cpanp perl v5.12.1 2010-04-26 CPANPLUS::Shell(3pm)
All times are GMT -4. The time now is 05:59 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy