How to create a script that takes a string and converts it to another managed string?How to run a shell script on a Unix console or Mac terminal?How do you run JavaScript script through the Terminal?How to execute a Ruby script in Terminal?How to activate the Scripts menu in iTerm2 on Mac?Can I convert a command line script into a AppleScript?How to stop creating .DS_Store on Mac?How to run Python script on terminalHow do I pause my shell script for a second before continuing?AppleScript: How to create and communicate with a singleton Terminal.app windowHow to decode base64 file path string in to apple script?

How to become an Editorial board member?

Why is this python script running in background consuming 100 % CPU?

Is it wise to pay off mortgage with 401k?

Is presenting a play showing Military characters in a bad light a crime in the US?

Are there historical examples of audiences drawn to a work that was "so bad it's good"?

Why did Nick Fury not hesitate in blowing up the plane he thought was carrying a nuke?

Do 'destroy' effects count as damage?

If the Charles SSL Proxy shows me sensitive data, is that data insecure/exposed?

Do seaplanes need to get clearance for takeoff?

How did Jean Parisot de Valette, 49th Grand Master of the Order of Malta, die?

What causes a person to remain in this world as a ghost?

How to say "invitation for war"?

Keeping the dodos out of the field

Mikrokosmos, BB 105, Vol. 1: No. 17 Contrary Motion (1) - Can't understand the structure

Reverse Array, Let Elements in New Array Equal Length of Original Array Elements - JavaScript

List of lists elementwise greater/smaller than

pwaS eht tirsf dna tasl setterl fo hace dorw

How should I mix small caps with digits or symbols?

Way of refund if scammed?

Connecting circles clockwise in TikZ

Hotel booking: Why is Agoda much cheaper than booking.com?

Circuit construction for execution of conditional statements using least significant bit

Buying a Mountain Bike from a friend

How do you cope with rejection?



How to create a script that takes a string and converts it to another managed string?


How to run a shell script on a Unix console or Mac terminal?How do you run JavaScript script through the Terminal?How to execute a Ruby script in Terminal?How to activate the Scripts menu in iTerm2 on Mac?Can I convert a command line script into a AppleScript?How to stop creating .DS_Store on Mac?How to run Python script on terminalHow do I pause my shell script for a second before continuing?AppleScript: How to create and communicate with a singleton Terminal.app windowHow to decode base64 file path string in to apple script?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















My intent is to capture the values of a string that I type and have those values be shifted to other letters. Essentially it would be a fake translation program or custom cipher generation script. Example of function:



I would type the sentence:



Who are you?



and the output would be shifted by lets say 1 to the next consonant or vowel, for example. The script would also need to know how to skip vowels or consonants as needed, and for the sake of argument y would always be considered a vowel. So the output would be:



Xju eso auy?



This is something I wanted to attempt for a creative writing project as a means of making another language. Ideally the shift variable could be an input as well to work with to find the best outcome. Possibly even variable shifts for vowels and consonants at the same time?










share|improve this question




























    0















    My intent is to capture the values of a string that I type and have those values be shifted to other letters. Essentially it would be a fake translation program or custom cipher generation script. Example of function:



    I would type the sentence:



    Who are you?



    and the output would be shifted by lets say 1 to the next consonant or vowel, for example. The script would also need to know how to skip vowels or consonants as needed, and for the sake of argument y would always be considered a vowel. So the output would be:



    Xju eso auy?



    This is something I wanted to attempt for a creative writing project as a means of making another language. Ideally the shift variable could be an input as well to work with to find the best outcome. Possibly even variable shifts for vowels and consonants at the same time?










    share|improve this question
























      0












      0








      0








      My intent is to capture the values of a string that I type and have those values be shifted to other letters. Essentially it would be a fake translation program or custom cipher generation script. Example of function:



      I would type the sentence:



      Who are you?



      and the output would be shifted by lets say 1 to the next consonant or vowel, for example. The script would also need to know how to skip vowels or consonants as needed, and for the sake of argument y would always be considered a vowel. So the output would be:



      Xju eso auy?



      This is something I wanted to attempt for a creative writing project as a means of making another language. Ideally the shift variable could be an input as well to work with to find the best outcome. Possibly even variable shifts for vowels and consonants at the same time?










      share|improve this question














      My intent is to capture the values of a string that I type and have those values be shifted to other letters. Essentially it would be a fake translation program or custom cipher generation script. Example of function:



      I would type the sentence:



      Who are you?



      and the output would be shifted by lets say 1 to the next consonant or vowel, for example. The script would also need to know how to skip vowels or consonants as needed, and for the sake of argument y would always be considered a vowel. So the output would be:



      Xju eso auy?



      This is something I wanted to attempt for a creative writing project as a means of making another language. Ideally the shift variable could be an input as well to work with to find the best outcome. Possibly even variable shifts for vowels and consonants at the same time?







      macos terminal applescript






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 23 at 19:58









      Helst0rmHelst0rm

      31




      31






















          1 Answer
          1






          active

          oldest

          votes


















          1














          If you truly are doing this for a creative writing project, then I submit that diving deep into the programming is not warranted. None of the input transformations you described require decisions to be made by the program. That is; once an encoding is chosen, the incoming letters will be each be firmly associated with outgoing letters. This greatly expands your options for how to achieve this, and greatly simplifies the complexity of the task.



          Since you tagged Terminal, here are a couple commands you could use in action:



          echo "Who are you?" | perl -pe 'tr/N-ZA-Mn-za-m/A-Za-z/'


          outputs: Jub ner lbh?

          This is the famous Rot13 "encoding" (all it does is substitute the letter that is 13 later in the alphabet). It's particularly handy as 13 is half the alphabet's 26, so putting some "encoded" text in will give you back the original text:



          echo "Jub ner lbh?" | perl -pe 'tr/N-ZA-Mn-za-m/A-Za-z/'


          outputs: Who are you?
          echo just sends text to the screen or other commands. Here we echo our text "How are you?" into a pipe | to pass it to the next command perl, which is a very powerful and flexible text-manipulation and reporting program. The rest of the line is just instructions for perl on how to spin 13 letters later in the alphabet.



          Quick note; normally hitting return runs the command in terminal. You can put a backslash at the end of a line though and hit return, it will then let you keep typing on the next line but treat it all as one command. Handy for lining things up.



          echo "How are you?" | tr 
          'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
          'DFVBTXEUWZOSHCJMAQYRINKLPGdfvbtxeuwzoshcjmaqyrinklpg'


          outputs: Ujk dqt pji?

          There's another command, tr. This example demonstrates an arbitrary substitution—in this case, random. It looks through that first long set of letters, and swaps in instead the letter in the second long set that is in the matching position. Since this substitution example is random, you could use this kind of mapping to create "Cryptogram" puzzles.



          The great thing about the tr command is that you can tell it to use whatever input-to-output "mapping" you'd like. Sure, it's a bit manual, but hey—no programming needed!



          Here's the mapping to achieve your requested "consonants and vowels" example shift:



          echo "Who are you?" | tr 
          'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
          'ECDFIGHJOKLMNPUQRSTVYWXZABecdfighjoklmnpuqrstvywxzab'


          Outputs: Xju esi auy? Not doing it by hand has its advantages—you missed a vowel in there.



          So if you need to rapidly try different mappings, consider learning a bit more about perl (or simpler: sed. or more complex: awk. Or or or…). If, instead, you don't mind a bit of careful command-construction, just lining up each incoming letter with your desired output letter, I think tr would serve nicely.






          share|improve this answer

























          • Thanks Joel! This is exactly what I was looking for. tr looks like the perfect method for what I'm hoping to accmplish

            – Helst0rm
            Mar 24 at 15:34











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55317808%2fhow-to-create-a-script-that-takes-a-string-and-converts-it-to-another-managed-st%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          If you truly are doing this for a creative writing project, then I submit that diving deep into the programming is not warranted. None of the input transformations you described require decisions to be made by the program. That is; once an encoding is chosen, the incoming letters will be each be firmly associated with outgoing letters. This greatly expands your options for how to achieve this, and greatly simplifies the complexity of the task.



          Since you tagged Terminal, here are a couple commands you could use in action:



          echo "Who are you?" | perl -pe 'tr/N-ZA-Mn-za-m/A-Za-z/'


          outputs: Jub ner lbh?

          This is the famous Rot13 "encoding" (all it does is substitute the letter that is 13 later in the alphabet). It's particularly handy as 13 is half the alphabet's 26, so putting some "encoded" text in will give you back the original text:



          echo "Jub ner lbh?" | perl -pe 'tr/N-ZA-Mn-za-m/A-Za-z/'


          outputs: Who are you?
          echo just sends text to the screen or other commands. Here we echo our text "How are you?" into a pipe | to pass it to the next command perl, which is a very powerful and flexible text-manipulation and reporting program. The rest of the line is just instructions for perl on how to spin 13 letters later in the alphabet.



          Quick note; normally hitting return runs the command in terminal. You can put a backslash at the end of a line though and hit return, it will then let you keep typing on the next line but treat it all as one command. Handy for lining things up.



          echo "How are you?" | tr 
          'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
          'DFVBTXEUWZOSHCJMAQYRINKLPGdfvbtxeuwzoshcjmaqyrinklpg'


          outputs: Ujk dqt pji?

          There's another command, tr. This example demonstrates an arbitrary substitution—in this case, random. It looks through that first long set of letters, and swaps in instead the letter in the second long set that is in the matching position. Since this substitution example is random, you could use this kind of mapping to create "Cryptogram" puzzles.



          The great thing about the tr command is that you can tell it to use whatever input-to-output "mapping" you'd like. Sure, it's a bit manual, but hey—no programming needed!



          Here's the mapping to achieve your requested "consonants and vowels" example shift:



          echo "Who are you?" | tr 
          'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
          'ECDFIGHJOKLMNPUQRSTVYWXZABecdfighjoklmnpuqrstvywxzab'


          Outputs: Xju esi auy? Not doing it by hand has its advantages—you missed a vowel in there.



          So if you need to rapidly try different mappings, consider learning a bit more about perl (or simpler: sed. or more complex: awk. Or or or…). If, instead, you don't mind a bit of careful command-construction, just lining up each incoming letter with your desired output letter, I think tr would serve nicely.






          share|improve this answer

























          • Thanks Joel! This is exactly what I was looking for. tr looks like the perfect method for what I'm hoping to accmplish

            – Helst0rm
            Mar 24 at 15:34















          1














          If you truly are doing this for a creative writing project, then I submit that diving deep into the programming is not warranted. None of the input transformations you described require decisions to be made by the program. That is; once an encoding is chosen, the incoming letters will be each be firmly associated with outgoing letters. This greatly expands your options for how to achieve this, and greatly simplifies the complexity of the task.



          Since you tagged Terminal, here are a couple commands you could use in action:



          echo "Who are you?" | perl -pe 'tr/N-ZA-Mn-za-m/A-Za-z/'


          outputs: Jub ner lbh?

          This is the famous Rot13 "encoding" (all it does is substitute the letter that is 13 later in the alphabet). It's particularly handy as 13 is half the alphabet's 26, so putting some "encoded" text in will give you back the original text:



          echo "Jub ner lbh?" | perl -pe 'tr/N-ZA-Mn-za-m/A-Za-z/'


          outputs: Who are you?
          echo just sends text to the screen or other commands. Here we echo our text "How are you?" into a pipe | to pass it to the next command perl, which is a very powerful and flexible text-manipulation and reporting program. The rest of the line is just instructions for perl on how to spin 13 letters later in the alphabet.



          Quick note; normally hitting return runs the command in terminal. You can put a backslash at the end of a line though and hit return, it will then let you keep typing on the next line but treat it all as one command. Handy for lining things up.



          echo "How are you?" | tr 
          'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
          'DFVBTXEUWZOSHCJMAQYRINKLPGdfvbtxeuwzoshcjmaqyrinklpg'


          outputs: Ujk dqt pji?

          There's another command, tr. This example demonstrates an arbitrary substitution—in this case, random. It looks through that first long set of letters, and swaps in instead the letter in the second long set that is in the matching position. Since this substitution example is random, you could use this kind of mapping to create "Cryptogram" puzzles.



          The great thing about the tr command is that you can tell it to use whatever input-to-output "mapping" you'd like. Sure, it's a bit manual, but hey—no programming needed!



          Here's the mapping to achieve your requested "consonants and vowels" example shift:



          echo "Who are you?" | tr 
          'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
          'ECDFIGHJOKLMNPUQRSTVYWXZABecdfighjoklmnpuqrstvywxzab'


          Outputs: Xju esi auy? Not doing it by hand has its advantages—you missed a vowel in there.



          So if you need to rapidly try different mappings, consider learning a bit more about perl (or simpler: sed. or more complex: awk. Or or or…). If, instead, you don't mind a bit of careful command-construction, just lining up each incoming letter with your desired output letter, I think tr would serve nicely.






          share|improve this answer

























          • Thanks Joel! This is exactly what I was looking for. tr looks like the perfect method for what I'm hoping to accmplish

            – Helst0rm
            Mar 24 at 15:34













          1












          1








          1







          If you truly are doing this for a creative writing project, then I submit that diving deep into the programming is not warranted. None of the input transformations you described require decisions to be made by the program. That is; once an encoding is chosen, the incoming letters will be each be firmly associated with outgoing letters. This greatly expands your options for how to achieve this, and greatly simplifies the complexity of the task.



          Since you tagged Terminal, here are a couple commands you could use in action:



          echo "Who are you?" | perl -pe 'tr/N-ZA-Mn-za-m/A-Za-z/'


          outputs: Jub ner lbh?

          This is the famous Rot13 "encoding" (all it does is substitute the letter that is 13 later in the alphabet). It's particularly handy as 13 is half the alphabet's 26, so putting some "encoded" text in will give you back the original text:



          echo "Jub ner lbh?" | perl -pe 'tr/N-ZA-Mn-za-m/A-Za-z/'


          outputs: Who are you?
          echo just sends text to the screen or other commands. Here we echo our text "How are you?" into a pipe | to pass it to the next command perl, which is a very powerful and flexible text-manipulation and reporting program. The rest of the line is just instructions for perl on how to spin 13 letters later in the alphabet.



          Quick note; normally hitting return runs the command in terminal. You can put a backslash at the end of a line though and hit return, it will then let you keep typing on the next line but treat it all as one command. Handy for lining things up.



          echo "How are you?" | tr 
          'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
          'DFVBTXEUWZOSHCJMAQYRINKLPGdfvbtxeuwzoshcjmaqyrinklpg'


          outputs: Ujk dqt pji?

          There's another command, tr. This example demonstrates an arbitrary substitution—in this case, random. It looks through that first long set of letters, and swaps in instead the letter in the second long set that is in the matching position. Since this substitution example is random, you could use this kind of mapping to create "Cryptogram" puzzles.



          The great thing about the tr command is that you can tell it to use whatever input-to-output "mapping" you'd like. Sure, it's a bit manual, but hey—no programming needed!



          Here's the mapping to achieve your requested "consonants and vowels" example shift:



          echo "Who are you?" | tr 
          'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
          'ECDFIGHJOKLMNPUQRSTVYWXZABecdfighjoklmnpuqrstvywxzab'


          Outputs: Xju esi auy? Not doing it by hand has its advantages—you missed a vowel in there.



          So if you need to rapidly try different mappings, consider learning a bit more about perl (or simpler: sed. or more complex: awk. Or or or…). If, instead, you don't mind a bit of careful command-construction, just lining up each incoming letter with your desired output letter, I think tr would serve nicely.






          share|improve this answer















          If you truly are doing this for a creative writing project, then I submit that diving deep into the programming is not warranted. None of the input transformations you described require decisions to be made by the program. That is; once an encoding is chosen, the incoming letters will be each be firmly associated with outgoing letters. This greatly expands your options for how to achieve this, and greatly simplifies the complexity of the task.



          Since you tagged Terminal, here are a couple commands you could use in action:



          echo "Who are you?" | perl -pe 'tr/N-ZA-Mn-za-m/A-Za-z/'


          outputs: Jub ner lbh?

          This is the famous Rot13 "encoding" (all it does is substitute the letter that is 13 later in the alphabet). It's particularly handy as 13 is half the alphabet's 26, so putting some "encoded" text in will give you back the original text:



          echo "Jub ner lbh?" | perl -pe 'tr/N-ZA-Mn-za-m/A-Za-z/'


          outputs: Who are you?
          echo just sends text to the screen or other commands. Here we echo our text "How are you?" into a pipe | to pass it to the next command perl, which is a very powerful and flexible text-manipulation and reporting program. The rest of the line is just instructions for perl on how to spin 13 letters later in the alphabet.



          Quick note; normally hitting return runs the command in terminal. You can put a backslash at the end of a line though and hit return, it will then let you keep typing on the next line but treat it all as one command. Handy for lining things up.



          echo "How are you?" | tr 
          'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
          'DFVBTXEUWZOSHCJMAQYRINKLPGdfvbtxeuwzoshcjmaqyrinklpg'


          outputs: Ujk dqt pji?

          There's another command, tr. This example demonstrates an arbitrary substitution—in this case, random. It looks through that first long set of letters, and swaps in instead the letter in the second long set that is in the matching position. Since this substitution example is random, you could use this kind of mapping to create "Cryptogram" puzzles.



          The great thing about the tr command is that you can tell it to use whatever input-to-output "mapping" you'd like. Sure, it's a bit manual, but hey—no programming needed!



          Here's the mapping to achieve your requested "consonants and vowels" example shift:



          echo "Who are you?" | tr 
          'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
          'ECDFIGHJOKLMNPUQRSTVYWXZABecdfighjoklmnpuqrstvywxzab'


          Outputs: Xju esi auy? Not doing it by hand has its advantages—you missed a vowel in there.



          So if you need to rapidly try different mappings, consider learning a bit more about perl (or simpler: sed. or more complex: awk. Or or or…). If, instead, you don't mind a bit of careful command-construction, just lining up each incoming letter with your desired output letter, I think tr would serve nicely.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 24 at 2:24

























          answered Mar 24 at 2:12









          Joel ReidJoel Reid

          6451510




          6451510












          • Thanks Joel! This is exactly what I was looking for. tr looks like the perfect method for what I'm hoping to accmplish

            – Helst0rm
            Mar 24 at 15:34

















          • Thanks Joel! This is exactly what I was looking for. tr looks like the perfect method for what I'm hoping to accmplish

            – Helst0rm
            Mar 24 at 15:34
















          Thanks Joel! This is exactly what I was looking for. tr looks like the perfect method for what I'm hoping to accmplish

          – Helst0rm
          Mar 24 at 15:34





          Thanks Joel! This is exactly what I was looking for. tr looks like the perfect method for what I'm hoping to accmplish

          – Helst0rm
          Mar 24 at 15:34



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55317808%2fhow-to-create-a-script-that-takes-a-string-and-converts-it-to-another-managed-st%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript