您的位置: 首页-> 电脑文摘-> 网页制作-> 其它-> 正文

长英文不自动换行的原因及解决方法
作者佚名 来源InterNet 加入时间:2004-11-24
一段没有空格的长英文,系统会认为它是一个单词,为了保持单词的完整性不会自动换行。其实这种情况不处理也可以,因为在实际应用中除了测试或有人捣乱不会出现这种情况,不过为了以防万一吧,我几个月前写了下面这个函数,只是一种权宜之计,为了对付恶意破坏者。 
 '------------------------------------------------- 

'  
; function name: autowrap 


'  description : 解决长英文不自动换行的问题 

'  parameters :  a_strSourceString :要转换的源字符串 

'                a_intSize , 每行宽度 

'  author:       bigeagle 

'  date :        2000/4/17 

'  history:      2000/4/17 : version 1.0 
'   
'------------------------------------------------------- 
  function AutoWrap(a_strSourceString , a_intSize) 
   
      dim l_strDestString 
       
      '如果内容中有回车则退出 
      'if instr(a_strSourceString , chr(13) + chr(10) ) <> 0 then 
      '   AutoWrap = replace(a_strSourceString , chr(13) + chr(10) , "") 
      '   exit function 
      'end if 
          
      'check if valid parameters 
      call assert(vartype(a_strSourceString) = 8 , "AutoWrap" , "a_strSourceString must be a string")  
      call assert(vartype(a_intSize) = 2 , "AutoWrap" , "a_intSize must be a integer") 
       
       
      dim i      
      if a_intSize >= len(a_strSourceString) then 
         l_strDestString = a_strSourceString 
      else 
       '  l_strDestString = left(a_strSourceString , a_intSize)    
         for i = 1 to len(a_strSourceString) step a_intSize 
             if instr( i , mid(a_strSourceString , i , a_intSize) , chr(32) ) = 0 _ 
                or instr( i , mid(a_strSourceString , i , a_intSize) , chr(13)+chr(10) )then 
                l_strDestString = l_strDestString + " " +  mid (a_strSourceString , i + 1 , a_intSize)         
             else 
                l_strDestString = l_strDestString + mid(a_strSourceString , i + 1 , a_intSize)                  
             end if    
         next 
      end if 
       
      call print("[AutoWrap:]return value is : '" + l_strDestString + "'") 
      l_strDestString = replace(l_strDestString , chr(13) + chr(10) , "") 
      AutoWrap =  l_strDestString  
  end function



[文章录入员:tonny]

相关文章 相关软件:
  • C++程序设计语言特别版(中文版+英文原版)
  • Access 2003 Step by Step(英文版)
  • Unix操作手册英文版 
  • tcpip英文帮助
  • 茶花女(英文)
  • 简爱(英文)
  • C# 参考手册英文版
  • ::PCBOOKCN'ADS::


    ::其它::
    DreamWeaver
    FrontPage
    FireWorks
    Flash
    HTML
    其它
    ::阅读排行::
    ·网页上传常见问题分析
    ·IIS 错误代码大汇总
    ·解决IIS5 HTTP500内部...
    ·网站制作之网页技巧
    ·全面了解了解Cookie
    ·长英文不自动换行的原因及解决方法
    ·CSS应用技巧十四例
    ·真正的文字竖排
    ·网站设计65条原则
    ·令网站提速的7大秘方