PDA

View Full Version : تبدیل کد php به کد asp.net



jasadeghi
سه شنبه 30 بهمن 1386, 15:53 عصر
سلام به تمامی دوستان

آیا سایتی هست که چند خط php رو به asp.net تبدیل کنه

الان من این کد رو دارم که می خوام معادل asp.net ش رو بدست بیارم



function html_to_utf8 ($data)
{
$data=utf8_encode($data);
return preg_replace("/\\&\\#([0-9]{3,10})\\;/e", '_html_to_utf8("\\1")' (file://\\1")'), $data);
}
function _html_to_utf8 ($data)
{
if ($data > 127)
{
$i = 5;
while (($i--) > 0)
{
if ($data != ($a = $data % ($p = pow(64, $i))))
{
$ret = chr(base_convert(str_pad(str_repeat(1, $i + 1), 8, "0"), 2, 10) + (($data - $a) / $p));
for ($i; $i > 0; $i--)
$ret .= chr(128 + ((($data % pow(64, $i)) - ($data % ($p = pow(64, $i - 1)))) / $p));
break;
}
}
}
else
$ret = "&#$data;";
return $ret;
}


با تشکر

raravaice
سه شنبه 30 بهمن 1386, 16:03 عصر
من تا حالا سایتی ندیدم ولی خود مایکروسافت یه چیزایی تدارک دیده.


http://msdn2.microsoft.com/en-us/asp.net/aa336639.aspx

موفق باشید

jasadeghi
سه شنبه 30 بهمن 1386, 16:43 عصر
ممنون از راهنمایتون

معادل این کد رو نمی دونید چی میشه؟

jasadeghi
سه شنبه 30 بهمن 1386, 21:02 عصر
سلام به همه دوستان

در اصل کاری که من میخواستم انجام بدم ارسال اس ام اس از طریق سایت با یک شماره اختصاصی که از یک شرکت طرف قرارداد با مخابرات بود.

این شرکت یک سری کدهایی رو به من داده تا بتونم با استفاده از این کد ها اس ام اس رو ارسال کنم . اما مشکل من چی بود ؟

اس ام اس انگلیسی ارسال می شد ولی فارسی رو به این صورت ؟؟؟؟ نشون می داد.

شرکت طرف قرار داد برای من یک کد php (که بالا گذاشتمش ) رو فرستاده بود که و گفته بود که با این کد مشکلت حل میشه.

بعد از کلی جستجو من به این کلاس برخوردم که مشکلم رو حل کرد. بد ندیدم اینجا قرارش بدم.



public class DirectEncoding : Encoding
{
public override int GetByteCount(char[] chars, int index, int count)
{
return count;
}

public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
{
for (int i=0; i<charCount; i++)
bytes[byteIndex+i]=(int)chars[charIndex+i]>255 ? (byte)'?' : (byte)chars[charIndex+i];
return charCount;
}

public override int GetCharCount(byte[] bytes, int index, int count)
{
return count;
}

public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
{
for (int i=0; i<byteCount; i++)
chars[charIndex+i]=(char)bytes[byteIndex+i];
return byteCount;
}

public override int GetMaxByteCount(int charCount)
{
return charCount;
}

public override int GetMaxCharCount(int byteCount)
{
return byteCount;
}
}

البته همونطور که متوجه شدید این کلاس مصارف بسیار زیادی داره .

امیدوارم به کار دوستان بیاد

شاد باشید و بهروز

mohammad87
دوشنبه 21 اسفند 1391, 15:56 عصر
این کدها رو می تونید به asp تبدیل کنید:

<?php

// Array indexes are 0-based, jCarousel positions are 1-based.
$first = max(0, intval($_GET['first']) - 1);
$last = max($first + 1, intval($_GET['last']) - 1);

$length = $last - $first + 1;

// ---

$images = array(
'http://static.flickr.com/66/199481236_dc98b5abb3_s.jpg',
'http://www.onextrapixel.com/examples/jquery-jcarousel-lite-and-jquery-captify/images/6.jpg',
'http://static.flickr.com/57/199481087_33ae73a8de_s.jpg',
'http://static.flickr.com/77/199481108_4359e6b971_s.jpg',
'http://static.flickr.com/58/199481143_3c148d9dd3_s.jpg',
'http://static.flickr.com/72/199481203_ad4cdcf109_s.jpg',
'http://static.flickr.com/58/199481218_264ce20da0_s.jpg',
'http://static.flickr.com/69/199481255_fdfe885f87_s.jpg',
'http://static.flickr.com/60/199480111_87d4cb3e38_s.jpg',
'http://static.flickr.com/70/229228324_08223b70fa_s.jpg',
);

$total = count($images);
$selected = array_slice($images, $first, $length);

// ---

header('Content-Type: text/xml');

echo '<data>';

// Return total number of images so the callback
// can set the size of the carousel.
echo ' <total>' . $total . '</total>';

foreach ($selected as $img) {
echo ' <image>' . $img . '</image>';
}

echo '</data>';

?>