home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxalgo.zip / TESTALGO / NoUmlaut.CMD < prev    next >
OS/2 REXX Batch file  |  1997-08-11  |  6KB  |  139 lines

  1. /* REXX *********************************************/
  2. /* Frame for your Rexx program. Verify please!      */
  3. /* Program name: NoUmlaut                           */
  4. /* Function    : Translate the umlauts to double    */
  5. /*             : bytes character string (ae, oe,    */
  6. /*             : ue, ss)                            */
  7. /* Syntax      :                                    */
  8. /* Changes     :                                    */
  9. /*                                                  */
  10. /* Made use of GREED.  20 Dec 1996 / 10:33:16   JRK */
  11. /****************************************************/
  12. Parse Arg string
  13.  
  14. /*==============(Exception handling)================*/
  15. Signal On Failure Name CLEANUP
  16. Signal On Halt    Name CLEANUP
  17. Signal On Syntax  Name CLEANUP
  18.  
  19. /*==========(Initialize RexxUtil support)===========*/
  20. If RxFuncQuery('SysLoadFuncs') Then Do
  21.   Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  22.   Call SysLoadFuncs
  23. End /* If RxFuncQuery... */
  24.  
  25. Say 
  26. Say Center( "( EXCLUDE MULTIPLE ITEMS )", 80, '*')
  27.  
  28. If Verify( string, 'äöüß', 'M' ) = 0 Then
  29.   string = '1ä 2Ä 3ü 4Ü 5ö 6Ö 7ß'
  30.  
  31. Say "NoUmlaut('"String"')    -->" NoUmlaut( string )
  32. Say "NoUmlaut('"String"', U) -->" NoUmlaut( string, 'U' )
  33. Say
  34. string = 'Jörg-Günter Meiß'
  35. Say "NoUmlaut('"String"')    -->" NoUmlaut( string )
  36. Say "NoUmlaut('"String"', U) -->" NoUmlaut( string, 'U' )
  37. Say
  38. /*================(End this program)================*/
  39. Call CharOut , "Press any key to exit "
  40. Call LineIn
  41.  
  42. Exit
  43.  
  44. CLEANUP:
  45.   Say
  46.   Say 'GREED001E - Break, Failure or Syntax Error'
  47. Exit
  48.  
  49.  
  50. /******************************************************/
  51. /*          PROCEDURES                                */
  52. /******************************************************/
  53. /*============( Remove umlaut characters )============*/
  54. /*                                                 14 */
  55. /* Name.......: NoUmlaut                              */
  56. /*                                                    */
  57. /* Function...: Replace umlaut characters with double */
  58. /*              character strings (ä -> ae, ö -> oe,  */ 
  59. /*              ü -> ue, ß -> ss)                     */
  60. /*                                                    */
  61. /* Call parm..: _string - string with umlauts,        */
  62. /*              _upper  - upper case return string    */
  63. /*                        (optional)                  */
  64. /*                                                    */
  65. /* Returns....: translated string                     */
  66. /*                                                    */
  67. /* Syntax.....:                                       */
  68. /*    tranStr = NoUmlaut( uString,['U'] )             */
  69. /*                                                    */
  70. /* Changes....: No                                    */
  71. /*                                                    */
  72. /* Note.......: This function calls the function      */
  73. /*              ReplaceUmlaut                         */
  74. /*                                                    */
  75. /* Author.....: Janosch R. Kowalczyk, 1996.           */
  76. /*====================================================*/
  77. NoUmlaut: Procedure
  78. Parse Arg _string, _upper
  79.  
  80. /*---------(Replace 'ä' 'Ä' by 'ae' 'Ae')-----------*/
  81. _string = ReplaceUmlaut( _string, 'ä', 'ae' )
  82. _string = ReplaceUmlaut( _string, 'Ä', 'Ae' )
  83.  
  84. /*---------(Replace 'ö' 'Ö' by 'oe' 'Oe')-----------*/
  85. _string = ReplaceUmlaut( _string, 'ö', 'oe' )
  86. _string = ReplaceUmlaut( _string, 'Ö', 'Oe' )
  87.  
  88. /*---------(Replace 'ü' 'Ü' by 'ue' 'Ue')-----------*/
  89. _string = ReplaceUmlaut( _string, 'ü', 'ue' )
  90. _string = ReplaceUmlaut( _string, 'Ü', 'Ue' )
  91.  
  92. /*-------------(Replace 'ß' by 'ss')----------------*/
  93. _string = ReplaceUmlaut( _string, 'ß', 'ss' )
  94.  
  95. If Abbrev('UPPER', _upper, 1) = 1 Then
  96.   Return Translate( _string )
  97.  
  98. Return _string
  99.  
  100. /*========( Replace a string with an another )========*/
  101. /*                                                    */
  102. /* Name.......: ReplaceUmlaut                         */
  103. /*                                                    */
  104. /* Function...: Find all occurences of a substring    */
  105. /*              and replace it by an another          */
  106. /*                                                    */
  107. /* Call parm..: _string  - input string,              */
  108. /*              _origin  - substring to be replaced   */
  109. /*              _replStr - replace substring          */
  110. /*                                                    */
  111. /* Returns....: translated string                     */
  112. /*                                                    */
  113. /* Syntax.....:                                       */
  114. /*    tranStr = ReplaceUmlaut( String, origin, repl ) */
  115. /*                                                    */
  116. /* Changes....: No                                    */
  117. /*                                                    */
  118. /* Note.......: This function is called from NoUmlaut */
  119. /*              and was developed for this purpose    */
  120. /*              only. It isn't able to replace sub-   */
  121. /*              strings that have same characters in  */
  122. /*              both - origin and replace string!     */
  123. /*                                                    */
  124. /* Author.....: Janosch R. Kowalczyk, 1996.           */
  125. /*====================================================*/
  126. ReplaceUmlaut: Procedure
  127. Parse Arg _string, _origin, _replStr
  128.  
  129. /*---( Same characters in the input and output strings )---*/
  130. If Verify( _origin, _replStr, 'M' ) > 0 Then Return _string
  131.  
  132. /*-----(Replace umlaut by combined characters)-----*/
  133. Do While Pos( _origin, _string ) > 0
  134.   Parse Var _string _prefix_ (_origin) _suffix_
  135.   _string = _prefix_ || _replStr || _suffix_
  136. End
  137.  
  138. Return _string
  139.