捐赠 | 广告 | 注册 | 发布 | 上传 | 关于我们    
  粤ICP备10103342号-1 DELPHI盒子 | 盒子文章 | 盒子问答悬赏 | 最新更新 | 盒子检索 | 下载中心 | 高级搜索    
  精品专区 | 繁體中文 | 奖励公告栏 | 直通车账号登陆 | 关闭GOOGLE广告 | 临时留言    
盒子资源分类
全部展开 - 全部合拢
D2010下intraweb开发中文显示?之部分解决方案!
关键字:intraweb 中文显示?
来 自:原创
平 台:Win2k/XP/NT,Win2003 下载所需:0 火柴
深浅度:中级 完成时间:2011/10/20
发布者:m523882802 发布时间:2011/11/5
编辑器:D2010 语  种:简体中文
分 类:数据库 下载浏览:170/5621
加入到我的收藏
下载错误报错
登陆以后才能下载
 用户名:
 密 码:
自动登陆(30天有效)
图片如果打不开,说明流量不够了,请稍候下载……
   小弟最近因公司需求开发B/S分销系统,IDE:XP SP3+D2010+SQL 2005
因第一次使用IW,中间遇到了不少难题。经过摸索总算解决了!
   最让人讨厌的就是这个中文显示?的问题了!一直在网上查找资料,近来找到了 这样一个单元 UTF8ContentParser.pas.供大家参考,如有不对之处还请指教!
   对一些如‘名,上’这样的字,我也没有找到这样的单元,D2010是包含了UTF8单元,但是没有彻底解决。我是绕过这样的字,用别的字代替!

  代码上传不过了?那我在下面贴出来了!
Google
 
本站原创作品,未经作者许可,严禁任何方式转载;转载作品,如果侵犯了您的权益,请联系我们
龙脉加密锁 15元起 Grid++Report 报表 申请支付@网
 相关文章
没有相关文章
相关评论
共有评论5条 当前显示最后5条评论
m523882802 2011/11/5 10:39:34
不给力呀,没看给顶呀!第一次发,也不清楚怎么上传源码.等了半个月了总算通过了。下面贴出单元 
unit UTF8ContentParser;

interface

uses SysUtils,
  Classes,
  Masks,
  Contnrs,
  HTTPApp,
  ReqFiles,
  HTTPParse;

type

  { TUTF8ContentParser }

  TUTF8ContentParser = class(TContentParser)

  private

    FContentFields: TStrings;

  public

    destructor Destroy; override;

    function GetContentFields: TStrings; override;

    class function CanParse(AWebRequest: TWebRequest): Boolean; override;

  end;

implementation

uses WebConst,
  WebComp,
  BrkrConst,
  Windows;

{ TUTF8ContentParser }

class function TUTF8ContentParser.CanParse(AWebRequest: TWebRequest): Boolean;

begin

  Result := True;

end;

destructor TUTF8ContentParser.Destroy;

begin

  FContentFields.Free;

  inherited Destroy;

end;

procedure ExtractHeaderFields(Separators, WhiteSpace: TSysCharSet; Content:
  PAnsiChar;

  Strings: TStrings; Decode: Boolean; Encoding: TEncoding; StripQuotes: Boolean
    = False); forward;

function TUTF8ContentParser.GetContentFields: TStrings;

begin

  if FContentFields = nil then

  begin

    FContentFields := TStringList.Create;

    if WebRequest.ContentLength > 0 then

    begin

      ExtractHeaderFields(['&'], [], PAnsiChar(WebRequest.RawContent),
        FContentFields, True, TEncoding.UTF8);

    end;

  end;

  Result := FContentFields;

end;

// Version of HTTP.ExtractHeaderFields that supports encoding parameter

procedure ExtractHeaderFields(Separators, WhiteSpace: TSysCharSet; Content:
  PAnsiChar;

  Strings: TStrings; Decode: Boolean; Encoding: TEncoding; StripQuotes: Boolean
    = False);

var

  Head, Tail        : PAnsiChar;

  EOS, InQuote, LeadQuote: Boolean;

  QuoteChar         : AnsiChar;

  ExtractedField    : AnsiString;

  WhiteSpaceWithCRLF: TSysCharSet;

  SeparatorsWithCRLF: TSysCharSet;

  procedure AddString(const S: AnsiString);

  var

    LBytes          : TBytes;

    LString         : string;

  begin

    LBytes := BytesOf(S);

    LString := Encoding.GetString(LBytes);

    Strings.Add(LString);

  end;

  function DoStripQuotes(const S: AnsiString): AnsiString;

  var

    I          : Integer;

    InStripQuote    : Boolean;

    StripQuoteChar  : AnsiChar;

  begin

    Result := S;

    InStripQuote := False;

    StripQuoteChar := #0;

    if StripQuotes then

      for I := Length(Result) downto 1 do

        if CharInSet(Result[I], ['''', '"']) then

          if InStripQuote and (StripQuoteChar = Result[I]) then

          begin

          Delete(Result, I, 1);

          InStripQuote := False;

          end

          else if not InStripQuote then

          begin

          StripQuoteChar := Result[I];

          InStripQuote := True;

          Delete(Result, I, 1);

          end

  end;

begin

  if (Content = nil) or (Content^ = #0) then Exit;

  WhiteSpaceWithCRLF := WhiteSpace + [#13, #10];

  SeparatorsWithCRLF := Separators + [#0, #13, #10, '"'];

  Tail := Content;

  QuoteChar := #0;

  repeat

    while CharInSet(Tail^, WhiteSpaceWithCRLF) do Inc(Tail);

    Head := Tail;

    InQuote := False;

    LeadQuote := False;

    while True do

    begin

      while (InQuote and not CharInSet(Tail^, [#0, '"'])) or

      not CharInSet(Tail^, SeparatorsWithCRLF) do Inc(Tail);

      if Tail^ = '"' then

      begin

        if (QuoteChar <> #0) and (QuoteChar = Tail^) then

          QuoteChar := #0

        else

        begin

          LeadQuote := Head = Tail;

          QuoteChar := Tail^;

          if LeadQuote then Inc(Head);

        end;

        InQuote := QuoteChar <> #0;

        if InQuote then

          Inc(Tail)

        else Break;

      end else Break;

    end;

    if not LeadQuote and (Tail^ <> #0) and (Tail^ = '"') then

      Inc(Tail);

    EOS := Tail^ = #0;

    if Head^ <> #0 then

    begin

      SetString(ExtractedField, Head, Tail - Head);

      if Decode then

        AddString(HTTPDecode(AnsiString(DoStripQuotes(ExtractedField))))

      else AddString(DoStripQuotes(ExtractedField));

    end;

    Inc(Tail);

  until EOS;

end;

initialization

  RegisterContentParser(TUTF8ContentParser);

end.
yxzzjg 2012/2/7 18:43:24
这个问题也困扰了我很久,是不是真能解决?这个文件如何使用?
请不吝赐教!!!
yxzzjg 2012/2/7 18:45:27


这个问题也困扰了我很久,是不是真能解决?这个文件如何使用?
请不吝赐教!!!
m523882802 2012/2/28 15:12:05
把UTF8ContentParser这个单元加入到你的DPR中,在需要使用的单元引用,应该就可以了!最近不怎么上盒子,抱歉各位盒友!
a200332 2015/1/24 0:36:50
不是 ,直接 在页面 更换成  gb2312 的 编码格式不就是 可以中文了
我要发表评论 查看全部评论
 
  DELPHI盒子版权所有 技术支持:深圳市麟瑞科技有限公司 1999-2024 V4.01 粤ICP备10103342号-1 更新RSS列表