JSP Tips

»ç¿ÀÁ¤
2008-07-15 16:26:19
IBM AS/400¿¡¼­ RPGÇÁ·Î±×·¥ È£Ãâ½Ã ¹®ÀÚ ±æÀÌ °è»ê

À̰Ͷ§¹®¿¡ ¸î³¯ ¸îÀÏ °í»ýÇ޴µ¥

Ȥ½Ã³ª ÇØ¼­ IBM AS/400¿¡¼­ JAVA·Î RPGÈ£Ãâ½Ã ¹®ÀÚ¿­ ±æÀÌ °è»êÀÌ ÇÊ¿äÇÒ¶§ ¿Ã·ÁµÓ´Ï´Ù.

 

// JAVA-SCRIPT ¹öÁ¯
 // OE / OF ±æÀÌ ¾Ë¾Æ¿À±â


 function get_OEOF_Length(sValue){

  var str = "";
  
  if (value != null && value.length > 0){
   
   str = value;
   
  }else{
   
   return 0;
   
  }
  
  
  var iStrLength = 0; // ¹®ÀÚ¿­ÀÇ ±æÀÌ

  // 1´ëÇѹα¹ , ´ë1ÇÑ ¹Î±¹ , ´ëÇѹα¹1 , 00
  for(var iLoop = 0 ; iLoop < str.length ; iLoop++){
   
   // 1 Byte ±ÛÀÚ¶ó¸é
   if (  ( str.charCodeAt(iLoop) > 0 ) && ( str.charCodeAt(iLoop) < 127 ) ){ 
    
    // ¾ÕÀÇ ±ÛÀÚ°¡ ¹®ÀÚ¿´´Ù¸é Á¾·áµÇ¹Ç·Î 1¹ÙÀÌÆ® Ãß°¡
    if ( iLoop > 0  && (  ( str.charCodeAt(iLoop - 1 ) < 0 ) || ( str.charCodeAt(iLoop - 1 ) > 127 ) ) ){ 
     
     iStrLength = iStrLength + 1;
     
    }
        
    iStrLength = iStrLength + 1;
    
    
   }else{          // 2 Byte ±ÛÀÚÀ϶§
        
    if (iLoop == 0 ){
     
     iStrLength += 1;
     
    }else{
     
     // ¾ÕÀÇ ±ÛÀÚ°¡ 1Byte ¹®ÀÚ¿´´Ù¸é 1¹ÙÀÌÆ® Ãß°¡
     if ( ( str.charCodeAt(iLoop - 1 ) > 0 ) && ( str.charCodeAt(iLoop - 1) < 127 ) ){ 
      iStrLength += 1;
     }
     
    }
    
    iStrLength = iStrLength + 2;
    
    if (iLoop == str.length - 1 ){
      
      iStrLength = iStrLength + 1;
          
    }    
    
   }

  }    
  
  return iStrLength;

 }

 

// JAVA ¹öÁ¯

 /**
  * ¼³¸í : value µÚ¿¡ length¿¡ ¸Â°Ô ºóÄ­ " " À» ä¿öÁØ´Ù
  * <b>±¸Çö¼³¸í</b>
  * <p> 
  * 1) ¿¹Á¦¹®ÀÚ => ´ëÄ¡ 1µ¿
  * ÇØ´ç ±ÛÀÚ¸¦ ¹è¿­¿¡ ³Ö°í
  * ÀüÀÚ°¡ ³ªÅ¸³ª¸é +2 ¹ÝÀÚ¸é +1
  * óÀ½ ÀüÀÚÀ̸é +1 ÀüÀÚ°¡ 긑³ª¸é +1
  * ƯÈ÷, ÀüÀÚ, ¹ÝÀÚ ½â¿© ÀÖÀ¸¸é ÀüÀÚµéÀÇ ½ÃÀÛÇÒ¶§ +11 ³¡³¯¶§ +1 À» ÇØÁÖ¾î¾ß ÇÕ´Ï´Ù.
  * ¿¹¸¦ µé¾î ´ëÄ¡1µ¿
  * ´ë ==> ÀüÀÚÀ̹ǷΠ¾Õ +1 + 2 = 3
  * Ä¡ ==> ÀüÀÚ           + 2 = 5
  * 1  ==> ¾Õ ÀüÀÚ Á¾·á +1 ¹ÝÀÚ +1 = 7
  * µ¿ ==> ÀüÀÚÀ̹ǷΠ¾Õ +1 + 2 = 10
  * ¸¶Áö¸·À¸·Î ¹Ù·Î ¾Õ¿¡ ÀüÀÚ·Î ³¡³µÀ¸¸é +1 = 11
  * 11 byte ÀÔ´Ï´Ù.
  * ÁÖÀÇÁ¡Àº °ø¹éµµ ÀüÀÚ·Î µé¾îÀÖ´Â °æ¿ì°¡ ÀÖÀ¸¹Ç·Î Æ÷ÇÔÇØ¼­ °è»êÇØ¾ß ÇÕ´Ï´Ù.
  * ±Û°í ±úÁø´Ù°í Çϴµ¥ ±úÁø sosi Äڵ尡 µé¾î ÀÖÀ¸¸é ÀÌ»óÇÏ°Ô µÉ¼öµµ ÀÖ½À´Ï´Ù.
  * ÁÖÀÇÇϽñ¸¿ä.
  *
  * 2) °£´ÜÇÑ ¿¹Á¦¹®ÀÚ
  * ½Å´ç1µ¿ ¶±»ÈÀÌ => (1 + 2) +  (2 + 1) +  (1) + (1 + 2 + 1) + (1) + (1 + 2) + (2) + (2 + 1) = 20
  *                                ½Å          ´ç           1         µ¿                      ¶±        »È       ÀÌ
  * </p>
  * @param value - ¹®ÀÚ¿­
  * @return int - ¹®ÀÚ¿­ÀÇ ±æÀÌ
  */
 public static int getLength(String value){

  String str = "";
  
  if (value != null && value.length() > 0){
   
   str = value;
   
  }else{
   
   return 0;
   
  }
  
  
  int iStrLength = 0; // ¹®ÀÚ¿­ÀÇ ±æÀÌ

  // 1´ëÇѹα¹ , ´ë1ÇÑ ¹Î±¹ , ´ëÇѹα¹1 , 00

  for(int iLoop = 0 ; iLoop < str.length() ; iLoop++){
   
   // ±ÛÀÚ°¡ ¾Æ´Ï¶ó¸é!(Ãʼº,Áß¼º,Á¾¼º Æ÷ÇÔ)
   if (  !( ( 0xac00 <= str.charAt( iLoop ) && str.charAt( iLoop ) <= 0xd7a3 ) || ( 0x3131 <= str.charAt( iLoop ) && str.charAt( iLoop ) <= 0x318E ) ) ){ 
    
    
    // ¾ÕÀÇ ±ÛÀÚ°¡ ¹®ÀÚ¿´´Ù¸é Á¾·áµÇ¹Ç·Î 1¹ÙÀÌÆ® Ãß°¡(Ãʼº ,Áß¼º ,Á¾¼ºÆ÷ÇÔ)
    if ( iLoop > 0 
      && ( ( 0xac00 <= str.charAt( iLoop -1 ) && str.charAt( iLoop -1 ) <= 0xd7a3 )  || ( 0x3131 <= str.charAt( iLoop - 1 ) && str.charAt( iLoop - 1 ) <= 0x318E ) ) ){ 
     
     iStrLength = iStrLength + 1;
     
    }
        
    iStrLength = iStrLength + 1;
    
    
   }else{          //
        
    if (iLoop == 0 ){
     
     iStrLength += 1;
     
    }else{
     
     // ¾ÕÀÇ ±ÛÀÚ°¡ ¼ýÀÚ¿´´Ù¸é 1¹ÙÀÌÆ® Ãß°¡(Ãʼº ,Áß¼º ,Á¾¼ºÆ÷ÇÔ)
     if ( !( ( 0xac00 <= str.charAt( iLoop -1) && str.charAt( iLoop -1) <= 0xd7a3 )  || ( 0x3131 <= str.charAt( iLoop - 1 ) && str.charAt( iLoop - 1 ) <= 0x318E ) ) ){ 
      iStrLength += 1;
     }
     
    }
    
    iStrLength = iStrLength + 2;
    
    if (iLoop == str.length() - 1 ){
      
      iStrLength = iStrLength + 1;
          
    }    
    
   }

  }   

  
  return iStrLength;
  
 }

Tag
tag´Â °Ô½Ã¹°ÀÇ ¼º°ÝÀ» ³ªÅ¸³»´Â Ű¿öµå¸¦ ÀÔ·ÂÇÏ´Â °ø°£ÀÔ´Ï´Ù.
tag´Â ·Î±×ÀÎ ÈÄ »ç¿ëÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.
´ÙÀ½±Û [err egov] 2.0.1 ÀÚµ¿ »ý¼ºµÈ »ùÇà ¾È µµ´Â °æ¿ì
>> 2753 IBM AS/400¿¡¼­ RPGÇÁ·Î±×·¥ È£Ãâ½Ã ¹®ÀÚ ±æÀÌ °è»ê  [0] »ç¿ÀÁ¤ 2645 2008-07-15 16:26:19
ÀÌÀü±Û web frameworks playoff seminar